QString: fix unintended copy in asprintf() return

On GCC, this function is NRVO'd, but depending on the definition of
va_list, a compiler may be unable to NRVO this function, in which case
the const on 's' prevents the implicit return by move.

Found by Coverity.

Fix by dropping the const. It doesn't hurt readability in such a short
function, shuts up Coverity, and may improve codegen on some
platforms.

Amends d251cae7b7.

Coverity-Id: 474158
Pick-to: 6.10 6.9 6.8
Change-Id: I4f842f690ea45c8db4c02f32f858d2700f57d128
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
This commit is contained in:
Marc Mutz 2025-08-19 11:47:50 +02:00
parent eaeeb6b5d3
commit a31a8da004
1 changed files with 1 additions and 1 deletions

View File

@ -7389,7 +7389,7 @@ QString QString::asprintf(const char *cformat, ...)
{
va_list ap;
va_start(ap, cformat);
const QString s = vasprintf(cformat, ap);
QString s = vasprintf(cformat, ap);
va_end(ap);
return s;
}