Details
-
Bug
-
Resolution: Fixed
-
P1: Critical
-
6.7
-
b892b39a7 (dev), e358eb3ba (6.8), 068f148b9 (6.7)
Description
From a comment to https://codereview.qt-project.org/c/qt/qtbase/+/568930
[2/3] Building CXX object tests/auto/corelib/global/qcomparehelpers/CMakeFiles/tst_qcomparehelpers_cpp23.dir/tst_qcomparehelpers.cpp.o FAILED: tests/auto/corelib/global/qcomparehelpers/CMakeFiles/tst_qcomparehelpers_cpp23.dir/tst_qcomparehelpers.cpp.o /mnt/b/yoe/master/build/tmp/work/riscv64-yoe-linux/qtbase/6.7.3/recipe-sysroot-native/usr/bin/riscv64-yoe-linux/riscv64-yoe-linux-clang++ --sysroot=/mnt/b/yoe/master/build/tmp/work/riscv64-yoe-linux/qtbase/6.7.3/recipe-sysroot -DQT_CORE_LIB -DQT_DISABLE_DEPRECATED_UP_TO=0x050000 -DQT_EXPLICIT_QFILE_CONSTRUCTION_FROM_PATH -DQT_LEAN_HEADERS=1 -DQT_NO_AS_CONST -DQT_NO_DEBUG -DQT_NO_FOREACH -DQT_NO_JAVA_STYLE_ITERATORS -DQT_NO_NARROWING_CONVERSIONS_IN_CONNECT -DQT_NO_QEXCHANGE -DQT_TESTCASE_BUILDDIR=\"\" -DQT_TESTCASE_SOURCEDIR=\"\" -DQT_TESTLIB_LIB -DQT_WARN_DEPRECATED_UP_TO=0x070000 -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -Dtst_QCompareHelpers=tst_QCompareHelpersCpp23 -I/mnt/b/yoe/master/build/tmp/work/riscv64-yoe-linux/qtbase/6.7.3/build-ptest/tests/auto/corelib/global/qcomparehelpers/tst_qcomparehelpers_cpp23_autogen/include -I/mnt/b/yoe/master/build/tmp/work/riscv64-yoe-linux/qtbase/6.7.3/git/tests/auto/corelib/global/qcomparehelpers -I/mnt/b/yoe/master/build/tmp/work/riscv64-yoe-linux/qtbase/6.7.3/build-ptest/tests/auto/corelib/global/qcomparehelpers -I/mnt/b/yoe/master/build/tmp/work/riscv64-yoe-linux/qtbase/6.7.3/build-ptest/include -isystem /mnt/b/yoe/master/build/tmp/work/riscv64-yoe-linux/qtbase/6.7.3/image/usr/include/QtTest/6.7.3 -isystem /mnt/b/yoe/master/build/tmp/work/riscv64-yoe-linux/qtbase/6.7.3/image/usr/include/QtTest/6.7.3/QtTest -isystem /mnt/b/yoe/master/build/tmp/work/riscv64-yoe-linux/qtbase/6.7.3/image/usr/include/QtCore/6.7.3 -isystem /mnt/b/yoe/master/build/tmp/work/riscv64-yoe-linux/qtbase/6.7.3/image/usr/include/QtCore/6.7.3/QtCore -isystem /mnt/b/yoe/master/build/tmp/work/riscv64-yoe-linux/qtbase/6.7.3/image/usr/include/QtCore -isystem /mnt/b/yoe/master/build/tmp/work/riscv64-yoe-linux/qtbase/6.7.3/image/usr/include -isystem /mnt/b/yoe/master/build/tmp/work/riscv64-yoe-linux/qtbase/6.7.3/image/usr/lib/mkspecs/linux-clang -isystem /mnt/b/yoe/master/build/tmp/work/riscv64-yoe-linux/qtbase/6.7.3/image/usr/include/QtTest -target riscv64-yoe-linux -mlittle-endian --dyld-prefix=/usr -Qunused-arguments -fstack-protector-strong -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=/mnt/b/yoe/master/build/tmp/work/riscv64-yoe-linux/qtbase/6.7.3/recipe-sysroot -O2 -pipe -g -feliminate-unused-debug-types -fmacro-prefix-map=/mnt/b/yoe/master/build/tmp/work/riscv64-yoe-linux/qtbase/6.7.3/git=/usr/src/debug/qtbase/6.7.3 -fdebug-prefix-map=/mnt/b/yoe/master/build/tmp/work/riscv64-yoe-linux/qtbase/6.7.3/git=/usr/src/debug/qtbase/6.7.3 -fmacro-prefix-map=/mnt/b/yoe/master/build/tmp/work/riscv64-yoe-linux/qtbase/6.7.3/build=/usr/src/debug/qtbase/6.7.3 -fdebug-prefix-map=/mnt/b/yoe/master/build/tmp/work/riscv64-yoe-linux/qtbase/6.7.3/build=/usr/src/debug/qtbase/6.7.3 -fdebug-prefix-map=/mnt/b/yoe/master/build/tmp/work/riscv64-yoe-linux/qtbase/6.7.3/recipe-sysroot= -fmacro-prefix-map=/mnt/b/yoe/master/build/tmp/work/riscv64-yoe-linux/qtbase/6.7.3/recipe-sysroot= -fdebug-prefix-map=/mnt/b/yoe/master/build/tmp/work/riscv64-yoe-linux/qtbase/6.7.3/recipe-sysroot-native= -fmacro-prefix-map=/mnt/b/yoe/master/build/tmp/work/riscv64-yoe-linux/qtbase/6.7.3/image= -fvisibility-inlines-hidden -DNDEBUG -O2 -std=gnu++23 -fPIE -fvisibility=hidden -fvisibility-inlines-hidden -Wall -Wextra -fexceptions -MD -MT tests/auto/corelib/global/qcomparehelpers/CMakeFiles/tst_qcomparehelpers_cpp23.dir/tst_qcomparehelpers.cpp.o -MF tests/auto/corelib/global/qcomparehelpers/CMakeFiles/tst_qcomparehelpers_cpp23.dir/tst_qcomparehelpers.cpp.o.d -o tests/auto/corelib/global/qcomparehelpers/CMakeFiles/tst_qcomparehelpers_cpp23.dir/tst_qcomparehelpers.cpp.o -c /mnt/b/yoe/master/build/tmp/work/riscv64-yoe-linux/qtbase/6.7.3/git/tests/auto/corelib/global/qcomparehelpers/tst_qcomparehelpers.cpp In file included from /mnt/b/yoe/master/build/tmp/work/riscv64-yoe-linux/qtbase/6.7.3/git/tests/auto/corelib/global/qcomparehelpers/tst_qcomparehelpers.cpp:4: In file included from /mnt/b/yoe/master/build/tmp/work/riscv64-yoe-linux/qtbase/6.7.3/git/tests/auto/corelib/global/qcomparehelpers/tst_qcomparehelpers.h:10: /mnt/b/yoe/master/build/tmp/work/riscv64-yoe-linux/qtbase/6.7.3/image/usr/include/QtTest/6.7.3/QtTest/private/qcomparisontesthelper_p.h:246:49: error: use of overloaded operator '==' is ambiguous (with operand types 'std::strong_ordering' and 'const partial_ordering') 246 | const bool expectedEqual = expectedOrdering == Qt::partial_ordering::equivalent; | ~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /mnt/b/yoe/master/build/tmp/work/riscv64-yoe-linux/qtbase/6.7.3/git/tests/auto/corelib/global/qcomparehelpers/tst_qcomparehelpers.cpp:29:5: note: in instantiation of function template specialization 'QTestPrivate::testAllComparisonOperators<IntWrapper, IntWrapper, std::strong_ordering>' requested here 29 | QT_TEST_ALL_COMPARISON_OPS(lhs, rhs, QtOrderingPrivate::to_std(expectedOrdering)); | ^ /mnt/b/yoe/master/build/tmp/work/riscv64-yoe-linux/qtbase/6.7.3/image/usr/include/QtTest/6.7.3/QtTest/private/qcomparisontesthelper_p.h:365:23: note: expanded from macro 'QT_TEST_ALL_COMPARISON_OPS' 365 | QTestPrivate::testAllComparisonOperators(Left, Right, Expected); \ | ^ /mnt/b/yoe/master/build/tmp/work/riscv64-yoe-linux/qtbase/6.7.3/git/tests/auto/corelib/global/qcomparehelpers/tst_qcomparehelpers.cpp:147:5: note: in instantiation of function template specialization 'tst_QCompareHelpersCpp23::compareImpl<IntWrapper, IntWrapper, Qt::strong_ordering>' requested here 147 | compareImpl<IntWrapper, IntWrapper, Qt::strong_ordering>(); | ^ /mnt/b/yoe/master/build/tmp/work/riscv64-yoe-linux/qtbase/6.7.3/recipe-sysroot/usr/include/c++/v1/__compare/ordering.h:213:47: note: candidate function 213 | _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(strong_ordering __v, _CmpUnspecifiedParam) noexcept { | ^ /mnt/b/yoe/master/build/tmp/work/riscv64-yoe-linux/qtbase/6.7.3/image/usr/include/QtCore/qcompare.h:175:27: note: candidate function (with reversed parameter order) 175 | friend constexpr bool operator==(partial_ordering lhs, std::partial_ordering rhs) noexcept | ^ /mnt/b/yoe/master/build/tmp/work/riscv64-yoe-linux/qtbase/6.7.3/image/usr/include/QtCore/qcompare.h:181:27: note: candidate function 181 | friend constexpr bool operator==(std::partial_ordering lhs, partial_ordering rhs) noexcept | ^
This is reproducible even with Clang 15.
A minimum reproducer is https://gcc.godbolt.org/z/T1szY7b7x
#include <compare> struct P { P(); P(std::partial_ordering); friend bool operator==(P, std::partial_ordering); }; int main() { P p; std::strong_ordering::equivalent == p; }
This code is UB, because comparison operators for standard comparison categories are poisoned: https://eel.is/c++draft/cmp#categories.pre-3
The relational and equality operators for the comparison category types are specified with an anonymous parameter of unspecified type.
This type shall be selected by the implementation such that these parameters can accept literal 0 as a corresponding argument.[Example 1: nullptr_t meets this requirement.
— end example]In this context, the behavior of a program that supplies an argument other than a literal 0 is undefined.
Clang is formally right here. We should at least work around this, and if we don't like the status quo, submit papers or library issues.
Attachments
For Gerrit Dashboard: QTBUG-126541 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
570666,3 | QCompare: add more relational operator overloads | dev | qt/qtbase | Status: MERGED | +2 | 0 |
578161,2 | QCompare: add more relational operator overloads | 6.8 | qt/qtbase | Status: MERGED | +2 | 0 |
578194,2 | QCompare: add more relational operator overloads | 6.7 | qt/qtbase | Status: MERGED | +2 | 0 |