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

Can not build with clang 4.0 using C++14

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P4: Low
    • 5.9.2
    • 5.9.1
    • Core: Other
    • None
    • Linux Red Hat 7
    • be93d2de031fb870a1ff244304311e07536a13b9

    Description

      In Qt 5.9.1, the definition of Q_REQUIRED_RESULT has changed in qcompilerdetection.h

       #if QT_HAS_CPP_ATTRIBUTE(nodiscard)         // P0188R1
       #  undef Q_REQUIRED_RESULT
       #  define Q_REQUIRED_RESULT [[nodiscard]]
       #endif
      

      Compiling our code with gcc (version 6.3.1) with -std=c++ 14 this works fine but when using clang (version 4.0.0) with -std=c++ 14 we get

      qcolor.h:194:5: error: use of the 'nodiscard' attribute is a C++1z extension
             [-Werror,-Wc++1z-extensions]
      

      We're using C++ 14 with a compiler supporting C++ 1z (clang 4.0.0) but providing  -std=c++14. It seems like you ignore compiler arguments with the __has_cpp_attribute check.

      define QT_HAS_CPP_ATTRIBUTE(x)       __has_cpp_attribute(x)
      

      You can not force users to set std=c++1z when using a modern compiler.

      We are using these cxx flags:

       -std=c++14 -pipe -pthread -Wall -Wextra -pedantic -Werror -pedantic-errors 

       

      Attachments

        Issue Links

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

          Activity

            People

              thiago Thiago Macieira
              pm Per-Magnus Holtmo
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes