Details
-
Bug
-
Resolution: Done
-
P2: Important
-
5.5.1, 5.7.0
-
None
-
Windows 7 x86_64
-
c365fa49d85810c6ad09bb5f43b5081cd7543bf1 (qt/qtbase/5.12)
Description
When attempting to format a string which happens to end in a percentage and contain a plural form I ended up writing a tr() line a bit like this:
auto str1 = QObject::tr("%n point(s) - %1%", "", 2).arg(QString::number(37.5f));
This worked fine in release, however in debug it asserts in QCoreApplication::replacePercentN() which calls at() beyond the final %. There's nothing about this string which makes that final % ambiguous, and that seems like a trivial indexing error. However if for some reason that input string shouldn't be allowed then the documentation should probably note it.
When the attached program is run we see:
ASSERT: "uint(i) < uint(size())" in file c:\qt\msvc2013\x86_64\5.5.1\qtbase\include\qtcore\../../src/corelib/tools/qstring.h, line 851 Debug Error! Program: C:\Qt\msvc2013\x86_64\5.5.1\qtbase\lib\Qt5Cored.dll Module: 5.5.1 File: global\qglobal.cpp Line: 2966 ASSERT: "uint(i) < uint(size())" in file c:\qt\msvc2013\x86_64\5.5.1\qtbase\include\qtcore\../../src/corelib/tools/qstring.h, line 851 (Press Retry to debug the application)