Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-123927

Three-way comparison operators in QJsonValueRef result in ambiguities and break build

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P0: Blocker
    • 6.8.0 FF
    • 6.8
    • Core: Other
    • None
    • faaee8212 (dev)

    Description

      Replacing the explicit operators with the ones implemented through the comparison macros in https://codereview.qt-project.org/c/qt/qtbase/+/548354 results in:

      /Users/vohi/qt/dev/qtdeclarative/tests/auto/qml/qmlimportscanner/tst_qmlimportscanner.cpp:180:21: error: use of overloaded operator '==' is ambiguous (with operand types 'QJsonValueRef' and 'QJsonObject')
                  if (*it == object) {
                      ~~~ ^  ~~~~~~
      /Users/vohi/qt/dev/qtbase/src/corelib/serialization/qjsonvalue.h:170:5: note: candidate function
          Q_DECLARE_EQUALITY_COMPARABLE(QJsonValueConstRef, QJsonValue)
          ^
      /Users/vohi/qt/dev/qtbase/src/corelib/global/qcomparehelpers.h:310:5: note: expanded from macro 'Q_DECLARE_EQUALITY_COMPARABLE'
          QT_OVERLOADED_MACRO(QT_DECLARE_EQUALITY_COMPARABLE, __VA_ARGS__)
          ^
      /Users/vohi/qt/dev-build/qtbase/include/QtCore/../../../../dev/qtbase/src/corelib/global/qoverload.h:76:59: note: expanded from macro 'QT_OVERLOADED_MACRO'
      #define QT_OVERLOADED_MACRO(MACRO, ...) QT_VA_ARGS_EXPAND(QT_OVERLOADED_MACRO_IMP(MACRO, QT_VA_ARGS_COUNT(__VA_ARGS__))(__VA_ARGS__))
                                                                ^
      /Users/vohi/qt/dev-build/qtbase/include/QtCore/../../../../dev/qtbase/src/corelib/global/qoverload.h:75:46: note: expanded from macro 'QT_OVERLOADED_MACRO_IMP'
      #define QT_OVERLOADED_MACRO_IMP(MACRO, ARGC) QT_OVERLOADED_MACRO_EXPAND(MACRO, ARGC)
                                                   ^
      note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
      <scratch space>:50:1: note: expanded from here
      QT_DECLARE_EQUALITY_COMPARABLE_2
      ^
      /Users/vohi/qt/dev/qtbase/src/corelib/global/qcomparehelpers.h:299:5: note: expanded from macro 'QT_DECLARE_EQUALITY_COMPARABLE_2'
          QT_DECLARE_EQUALITY_OPERATORS_HELPER(LeftType, RightType, /* non-constexpr */, \
          ^
      /Users/vohi/qt/dev/qtbase/src/corelib/global/qcomparehelpers.h:197:27: note: expanded from macro 'QT_DECLARE_EQUALITY_OPERATORS_HELPER'
          friend Constexpr bool operator==(LeftType const &lhs, RightType const &rhs) \
                                ^
      /Users/vohi/qt/dev/qtbase/src/corelib/serialization/qjsonobject.h:248:5: note: candidate function
          Q_DECLARE_EQUALITY_COMPARABLE(QJsonObject, QJsonValue)
          ^
      /Users/vohi/qt/dev/qtbase/src/corelib/global/qcomparehelpers.h:310:5: note: expanded from macro 'Q_DECLARE_EQUALITY_COMPARABLE'
          QT_OVERLOADED_MACRO(QT_DECLARE_EQUALITY_COMPARABLE, __VA_ARGS__)
          ^
      /Users/vohi/qt/dev-build/qtbase/include/QtCore/../../../../dev/qtbase/src/corelib/global/qoverload.h:76:59: note: expanded from macro 'QT_OVERLOADED_MACRO'
      #define QT_OVERLOADED_MACRO(MACRO, ...) QT_VA_ARGS_EXPAND(QT_OVERLOADED_MACRO_IMP(MACRO, QT_VA_ARGS_COUNT(__VA_ARGS__))(__VA_ARGS__))
                                                                ^
      /Users/vohi/qt/dev-build/qtbase/include/QtCore/../../../../dev/qtbase/src/corelib/global/qoverload.h:75:46: note: expanded from macro 'QT_OVERLOADED_MACRO_IMP'
      #define QT_OVERLOADED_MACRO_IMP(MACRO, ARGC) QT_OVERLOADED_MACRO_EXPAND(MACRO, ARGC)
                                                   ^
      note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
      <scratch space>:118:1: note: expanded from here
      QT_DECLARE_EQUALITY_COMPARABLE_2
      ^
      /Users/vohi/qt/dev/qtbase/src/corelib/global/qcomparehelpers.h:301:5: note: expanded from macro 'QT_DECLARE_EQUALITY_COMPARABLE_2'
          QT_DECLARE_EQUALITY_OPERATORS_REVERSED_HELPER(LeftType, RightType, /* non-constexpr */, \
          ^
      /Users/vohi/qt/dev/qtbase/src/corelib/global/qcomparehelpers.h:208:27: note: expanded from macro 'QT_DECLARE_EQUALITY_OPERATORS_REVERSED_HELPER'
          friend Constexpr bool operator==(RightType const &lhs, LeftType const &rhs) \
                                ^
      1 error generated.
      ninja: build stopped: subcommand failed.
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            tatiana.borisova Tatiana Borisova
            vhilshei Volker Hilsheimer
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes