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

QString in std::vector triggers gcc's -Wnull-dereference

    XMLWordPrintable

Details

    • Bug
    • Resolution: Cannot Reproduce
    • P2: Important
    • None
    • 5.12.3
    • None
    • Linux/Other display system

    Description

      The following code triggers `-Wnull-dereference` under GCC 9.1:

      #include <vector>
      
      #include <QString>
      
      int main()
       {
          std::vector<QString> const a\{""};
      
          auto const t = a;
      
          return t.size() == 0;
       }
      
      /tmp % g++ -std=c++17 -Werror=null-dereference -I/usr/include/qt5/QtCore -I/usr/include/qt5 -fPIC -c -O1 t.cpp
      In file included from /usr/include/qt5/QtCore/qglobal.h:105,
       from /usr/include/qt5/QtCore/qchar.h:43,
       from /usr/include/qt5/QtCore/qstring.h:48,
       from /usr/include/qt5/QtCore/QString:1,
       from t.cpp:3:
      /usr/include/qt5/QtCore/qstring.h: In function 'int main()':
      /usr/include/qt5/QtCore/qcompilerdetection.h:1129:26: error: null pointer dereference [-Werror=null-dereference]
       1129 | # define Q_DECL_NOEXCEPT noexcept
       | ^~~~~~~~
      /usr/include/qt5/QtCore/qcompilerdetection.h:1139:25: note: in expansion of macro 'Q_DECL_NOEXCEPT'
       1139 | # define Q_DECL_NOTHROW Q_DECL_NOEXCEPT
       | ^~~~~~~~~~~~~~~
      /usr/include/qt5/QtCore/qstring.h:957:47: note: in expansion of macro 'Q_DECL_NOTHROW'
       957 | inline QString::QString(const QString &other) Q_DECL_NOTHROW : d(other.d)
       | ^~~~~~~~~~~~~~
      In file included from /usr/include/qt5/QtCore/QString:1,
       from t.cpp:3:
      /usr/include/qt5/QtCore/qstring.h:957:73: error: null pointer dereference [-Werror=null-dereference]
       957 | inline QString::QString(const QString &other) Q_DECL_NOTHROW : d(other.d)
       | ^
      cc1plus: some warnings being treated as errors
      

      Attachments

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

        Activity

          People

            thiago Thiago Macieira
            hannesscheer Johannes Scheer
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes