Details
-
Bug
-
Resolution: Out of scope
-
Not Evaluated
-
None
-
6.4.2
-
None
Description
There is a bug in the error reporting for `template <typename Args> QString QString::arg(Args &&... args) const`
If an nth argument is invalid, it reports that the (n+1)th argument is invalid and sometimes the (n-1)th argument.
Try
#include <QCoreApplication> #include <QString>int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); auto s = QString("This has arguments. int: %1, qint64: %2, QString: %3") .arg("Hello", qint64(96000), "world"); return a.exec(); }
which has a `qint64` as the 2nd argument, for which there is no implicit conversion. However the errors report there is no known conversion for the 1st & 3rd argument but not the 2nd argument:
/Users/me/Code/QtBugQStringArg/main.cpp:9: error: no matching member function for call to 'arg'/Users/me/Code/QtBugQStringArg/main.cpp:9:19: error: no matching member function for call to 'arg' .arg("Hello", qint64(96000), "world"); ~^~~ /Users/me/Qt/6.4.2/macos/lib/QtCore.framework/Headers/qstring.h:520:27: note: candidate function not viable: no known conversion from 'const char[6]' to 'QChar' for 3rd argument [[nodiscard]] QString arg(const QString &a, int fieldWidth = 0, ^ /Users/me/Qt/6.4.2/macos/lib/QtCore.framework/Headers/qstring.h:498:27: note: candidate function not viable: no known conversion from 'const char[6]' to 'qlonglong' (aka 'long long') for 1st argument [[nodiscard]] QString arg(qlonglong a, int fieldwidth=0, int base=10, ^ /Users/me/Qt/6.4.2/macos/lib/QtCore.framework/Headers/qstring.h:500:27: note: candidate function not viable: no known conversion from 'const char[6]' to 'qulonglong' (aka 'unsigned long long') for 1st argument [[nodiscard]] QString arg(qulonglong a, int fieldwidth=0, int base=10, ^ /Users/me/Qt/6.4.2/macos/lib/QtCore.framework/Headers/qstring.h:514:27: note: candidate function not viable: no known conversion from 'const char[6]' to 'double' for 1st argument [[nodiscard]] QString arg(double a, int fieldWidth = 0, char format = 'g', int precision = -1, ^ /Users/me/Qt/6.4.2/macos/lib/QtCore.framework/Headers/qstring.h:516:27: note: candidate function not viable: no known conversion from 'const char[6]' to 'char' for 1st argument [[nodiscard]] QString arg(char a, int fieldWidth = 0, ^ /Users/me/Qt/6.4.2/macos/lib/QtCore.framework/Headers/qstring.h:518:27: note: candidate function not viable: no known conversion from 'const char[6]' to 'QChar' for 1st argument [[nodiscard]] QString arg(QChar a, int fieldWidth = 0, ^ /Users/me/Qt/6.4.2/macos/lib/QtCore.framework/Headers/qstring.h:522:27: note: candidate function not viable: no known conversion from 'const char[6]' to 'QStringView' for 1st argument [[nodiscard]] QString arg(QStringView a, int fieldWidth = 0, ^ /Users/me/Qt/6.4.2/macos/lib/QtCore.framework/Headers/qstring.h:524:27: note: candidate function not viable: no known conversion from 'const char[6]' to 'QLatin1StringView' (aka 'QLatin1String') for 1st argument [[nodiscard]] QString arg(QLatin1StringView a, int fieldWidth = 0, ^ /Users/me/Qt/6.4.2/macos/lib/QtCore.framework/Headers/qstring.h:1288:25: note: candidate function not viable: no known conversion from 'const char[6]' to 'int' for 1st argument inline QString QString::arg(int a, int fieldWidth, int base, QChar fillChar) const ^ /Users/me/Qt/6.4.2/macos/lib/QtCore.framework/Headers/qstring.h:1290:25: note: candidate function not viable: no known conversion from 'const char[6]' to 'uint' (aka 'unsigned int') for 1st argument inline QString QString::arg(uint a, int fieldWidth, int base, QChar fillChar) const ^ /Users/me/Qt/6.4.2/macos/lib/QtCore.framework/Headers/qstring.h:1292:25: note: candidate function not viable: no known conversion from 'const char[6]' to 'long' for 1st argument inline QString QString::arg(long a, int fieldWidth, int base, QChar fillChar) const ^ /Users/me/Qt/6.4.2/macos/lib/QtCore.framework/Headers/qstring.h:1294:25: note: candidate function not viable: no known conversion from 'const char[6]' to 'ulong' (aka 'unsigned long') for 1st argument inline QString QString::arg(ulong a, int fieldWidth, int base, QChar fillChar) const ^ /Users/me/Qt/6.4.2/macos/lib/QtCore.framework/Headers/qstring.h:1296:25: note: candidate function not viable: no known conversion from 'const char[6]' to 'short' for 1st argument inline QString QString::arg(short a, int fieldWidth, int base, QChar fillChar) const ^ /Users/me/Qt/6.4.2/macos/lib/QtCore.framework/Headers/qstring.h:1298:25: note: candidate function not viable: no known conversion from 'const char[6]' to 'ushort' (aka 'unsigned short') for 1st argument inline QString QString::arg(ushort a, int fieldWidth, int base, QChar fillChar) const ^ /Users/me/Qt/6.4.2/macos/lib/QtCore.framework/Headers/qstring.h:550:5: note: candidate template ignored: requirement 'std::is_same<QtPrivate::BoolList<true, false, true, true>, QtPrivate::BoolList<true, true, false, true>>::value' was not satisfied [with Args = <const char (&)[6], long long, const char (&)[6]>] arg(Args &&...args) const ^