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

C++23 [[assume]] added in 6.10.0 creates warnings when compiling in C++20 mode with -Wextra -pedantic

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3: Somewhat important P3: Somewhat important
    • 6.10.1, 6.11.0 Beta3
    • 6.10.0
    • None
    • macOS Seqouia 15.7.1, Xcode 26.0.1, Apple clang version 17.0.0 (clang-1700.3.19.1)
    • All
    • 0a0aed0fc (dev), a6ac84731 (6.10)

      When compiling vs. Qt headers >= 6.10.0, using `-Werror -pedantic`, and in C++20 mode, one may get a lot warnings such as the following:

       
      In file included from /Users/calin/Qt512/6.10.0/macos/lib/QtCore.framework/Headers/QHash:1:
      In file included from /Users/calin/Qt512/6.10.0/macos/lib/QtCore.framework/Headers/qhash.h:12:
      /Users/calin/Qt512/6.10.0/macos/lib/QtCore.framework/Headers/qlist.h:451:11: warning: use of the 'assume' attribute is a C++23 extension [-Wc++23-attribute-extensions]
      

       

      This is due to changes such as in this commit, new to 6.10.0: https://github.com/qt/qtbase/commit/84467d70a831eea78f288f76fff91c5def01f14f

       

      To reproduce, add the flags using e.g. qmake as so to any project compiled against Qt 6.10.0: 

      qmake -o foo foo.pro 'QMAKE_CXXFLAGS+=-Wextra -pedantic' CONFIG+=c++20

       

      Some comments:

       

      • The committer wrongly asserts that [[assume]] is a C+20 attribute. It is not. It is a C+23 attribute. Reference: https://en.cppreference.com/w/cpp/language/attributes/assume
      • clang in C++20 mode will return true to `__has_cpp_attribute(assume)`, sadly.
      • But it still warns about the attribute being used if in C++20 mode.

       

      I am not sure how you guys can resolve this but this is very annoying to users because compiling with `-Wextra -pedantic` is not uncommon.

       

      This is new in the 6.10.x series. In 6.9.x and before everything compiles without warnings.

       

      Please fix.

       

        For Gerrit Dashboard: QTBUG-141074
        # Subject Branch Project Status CR V

            thiago Thiago Macieira
            cculianu calin culianu
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes