diff --git a/src/corelib/text/qstring.h b/src/corelib/text/qstring.h index a1d130c2b17..f3759718bc8 100644 --- a/src/corelib/text/qstring.h +++ b/src/corelib/text/qstring.h @@ -316,7 +316,12 @@ public: [[nodiscard]] QString arg(T a, int fieldWidth = 0, int base = 10, QChar fillChar = u' ') const { - if constexpr (std::is_signed_v) + using U = typename std::conditional< + // underlying_type_t is UB in C++17/SFINAE in C++20, so wrap: + std::is_enum_v, std::underlying_type, + q20::type_identity + >::type::type; + if constexpr (std::is_signed_v) return arg_impl(qlonglong(a), fieldWidth, base, fillChar); else return arg_impl(qulonglong(a), fieldWidth, base, fillChar); diff --git a/tests/auto/corelib/text/qstring/tst_qstring.cpp b/tests/auto/corelib/text/qstring/tst_qstring.cpp index 11e2232133d..d4a041a6c15 100644 --- a/tests/auto/corelib/text/qstring/tst_qstring.cpp +++ b/tests/auto/corelib/text/qstring/tst_qstring.cpp @@ -6697,7 +6697,6 @@ void tst_QString::arg() // (unscoped) enums enum : int { FooS = -1 }; enum : uint { FooU = 1 }; - QEXPECT_FAIL("", "QTBUG-131906", Continue); // Qt 6.9 only QCOMPARE(s4.arg(FooS), QLatin1String("[-1]")); QCOMPARE(s4.arg(FooU), QLatin1String("[1]"));