summaryrefslogtreecommitdiffstats
path: root/src/corelib/text/qstring.cpp
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2025-08-19 11:47:50 +0200
committerMarc Mutz <marc.mutz@qt.io>2025-08-20 11:44:29 +0200
commita31a8da004c3381c5a0aa2acf5c0a2d5eb33f427 (patch)
tree9c7025d5c9ea5527b19f24b139ac1df30eb1efc6 /src/corelib/text/qstring.cpp
parenteaeeb6b5d38afc3ef249dfd827dad1181bef14d2 (diff)
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 <edward.welbourne@qt.io>
Diffstat (limited to 'src/corelib/text/qstring.cpp')
-rw-r--r--src/corelib/text/qstring.cpp2
1 files changed, 1 insertions, 1 deletions
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;
}