From a31a8da004c3381c5a0aa2acf5c0a2d5eb33f427 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 19 Aug 2025 11:47:50 +0200 Subject: [PATCH] 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 d251cae7b7370af328307948aca9bb63def22fe4. Coverity-Id: 474158 Pick-to: 6.10 6.9 6.8 Change-Id: I4f842f690ea45c8db4c02f32f858d2700f57d128 Reviewed-by: Edward Welbourne --- src/corelib/text/qstring.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/text/qstring.cpp b/src/corelib/text/qstring.cpp index 0bfca931bfb..3d95851c587 100644 --- a/src/corelib/text/qstring.cpp +++ b/src/corelib/text/qstring.cpp @@ -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; }