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

Use of std::aligned_union and std::aligned_union_t deprecated in C++23

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P3: Somewhat important
    • 6.4.1, 6.5.0 Beta1
    • 6.4.0
    • Core: Other
    • None
    • Windows 10, MSVC2022
    • Windows
    • fdd0a1bc17 (qt/qtbase/dev) fdd0a1bc17 (qt/tqtc-qtbase/dev) ae4f63613b (qt/qtbase/6.4) ae4f63613b (qt/tqtc-qtbase/6.4) ae4f63613b (qt/tqtc-qtbase/tqtc/qtinsight-6.4)

    Description

      Building with Visual Studio 2022, and setting the -headersclean option results in the following C++23 warning-treated-as-error:

      S:/Jenkins/workspace/qt_maya/src/qtbase/src/corelib/kernel/qapplicationstatic.h(20): error C2220: the following warning is treated as an error
      S:/Jenkins/workspace/qt_maya/src/qtbase/src/corelib/kernel/qapplicationstatic.h(20): warning C4996: 'std::aligned_union_t': warning STL4035: std::aligned_union and std::aligned_union_t are deprecated in C++23. Prefer alignas(Ts...) std::byte t_buff[std::max({sizeof(Ts)...})]. You can define _SILENCE_CXX23_ALIGNED_UNION_DEPRECATION_WARNING or _SILENCE_ALL_CXX23_DEPRECATION_WARNINGS to acknowledge that you have received this warning.
      S:/Jenkins/workspace/qt_maya/src/qtbase/src/corelib/kernel/qapplicationstatic.h(64): note: see reference to class template instantiation 'QtGlobalStatic::ApplicationHolder<QAS>' being compiled
      

      As this is a C++23 standard deprecation, and C++17 was detected as the c++std to use, I think this is erroneous.

      This is caused by the following snippet from qtbase/cmake/QtHeadersClean.cmake:

          elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
              # -Za would enable strict standards behavior, but we can't add it because
              # <windows.h> and <GL.h> violate the standards.
              set(hcleanFLAGS -std:c++latest -Zc:__cplusplus -WX -W3)
      

      I do not think this should be using -std:c++latest, but instead honoring the c++std selected or detected during configure.

      This is the full configure line I used:

      set MODULES_TO_SKIP=-skip qtnetworkauth -skip qtpurchasing -skip qtquickcontrols -skip qtquick3d -skip qtlottie -skip qtcharts -skip qtdatavis3d -skip qtvirtualkeyboard -skip qtscript -skip qtwayland -skip qtwebglplugin -skip qtactiveqt -skip qtconnectivity -skip qtcoap -skip qtmqtt -skip qtopcua -skip qtquicktimeline
      
      call %SOURCE_DIR%\configure -opensource -confirm-license -prefix %INSTALL_DIR% -debug-and-release -nomake tests -nomake examples -force-debug-info -headersclean -optimized-tools -opengl desktop -feature-qtwebengine-build %MODULES_TO_SKIP% -openssl-runtime -- -DOPENSSL_ROOT_DIR=%OPENSSL_ROOT_DIR%
      

      Attachments

        Issue Links

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

          Activity

            People

              mmutz Marc Mutz
              kkyzivat Keith Kyzivat
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes