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

GCC 9: QList header yields -Wdeprecated-copy warning

    XMLWordPrintable

Details

    • Linux/X11
    • ef05c48898e90e4ff40d8c4493f4b80bc22c1703

    Description

      The following code issues a warning when compiled with GCC 9:

      $ cat test.C
      #include <QList>
      
      int main(int argc, char** argv) {
      
        QList<int> a;
        a.append(1);
        a.removeFirst();
        return 0;
      }
      
      $ g++ -std=c++11 -Werror -Wextra -fPIC -I/usr/include/qt -I/usr/include/qt/QtCore -lQt5Core -o test test.C
      
      In file included from /usr/include/qt/QtCore/QList:1,
                       from test.C:1:
      /usr/include/qt/QtCore/qlist.h: In instantiation of ‘QList<T>::iterator QList<T>::erase(QList<T>::iterator) [with T = int]’:
      /usr/include/qt/QtCore/qlist.h:353:55:   required from ‘void QList<T>::removeFirst() [with T = int]’
      test.C:7:17:   required from here
      /usr/include/qt/QtCore/qlist.h:536:12: error: implicitly-declared ‘QList<int>::iterator& QList<int>::iterator::operator=(const QList<int>::iterator&)’ is deprecated [-Werror=deprecated-copy]
        536 |         it = begin(); // implies detach()
      /usr/include/qt/QtCore/qlist.h:239:16: note: because ‘QList<int>::iterator’ has user-provided ‘QList<T>::iterator::iterator(const QList<T>::iterator&) [with T = int]’
        239 |         inline iterator(const iterator &o) Q_DECL_NOTHROW : i(o.i){}
            |                ^~~~~~~~
      cc1plus: all warnings being treated as errors
      

      Attachments

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

        Activity

          People

            thiago Thiago Macieira
            bastianbeischer Bastian Beischer
            Votes:
            3 Vote for this issue
            Watchers:
            10 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes