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

QVector with QT_STRICT_ITERATORS causes many warnings with g++

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Not Evaluated
    • Resolution: Done
    • Affects Version/s: 5.15.5
    • Fix Version/s: 6.0.0
    • Labels:
      None
    • Environment:
      g++ 10.2.1
    • Platform/s:
      Linux/X11

      Description

      When QT_STRICT_ITERATORS is enabled, g++ 10 generates a lot of warnings when QVector is used.

       

      #include <QVector>
      
      void f()
      {
      	QVector<int> foo;
      	foo.takeAt(0);
      }
      
      
      g++ -c -pipe -O2 -std=gnu++1z -Wall -Wextra -D_REENTRANT -fPIC -DQT_STRICT_ITERATORS -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -I. -I/opt/qt515/include -I/opt/qt515/include/QtGui -I/opt/qt515/include/QtCore -Irelease -I/opt/qt515/mkspecs/linux-g++ -o release/main.o main.cpp
      In file included from /opt/qt515/include/QtCore/QVector:1,
                       from main.cpp:1:
      /opt/qt515/include/QtCore/qvector.h: In instantiation of 'QVector<T>::iterator QVector<T>::erase(QVector<T>::iterator, QVector<T>::iterator) [with T = int; QVector<T>::iterator = QTypedArrayData<int>::iterator]':
      /opt/qt515/include/QtCore/qvector.h:478:8:   required from 'void QVector<T>::remove(int) [with T = int]'
      /opt/qt515/include/QtCore/qvector.h:189:58:   required from 'T QVector<T>::takeAt(int) [with T = int]'
      main.cpp:6:14:   required from here
      /opt/qt515/include/QtCore/qvector.h:914:16: warning: implicitly-declared 'constexpr QTypedArrayData<int>::iterator& QTypedArrayData<int>::iterator::operator=(const QTypedArrayData<int>::iterator&)' is deprecated [-Wdeprecated-copy]
        914 |         abegin = d->begin() + itemsUntouched;
            |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      In file included from /opt/qt515/include/QtCore/qvector.h:46,
                       from /opt/qt515/include/QtCore/QVector:1,
                       from main.cpp:1:
      /opt/qt515/include/QtCore/qarraydata.h:144:16: note: because 'QTypedArrayData<int>::iterator' has user-provided 'QTypedArrayData<T>::iterator::iterator(const QTypedArrayData<T>::iterator&) [with T = int]'
        144 |         inline iterator(const iterator &o): i(o.i){} // #### Qt 6: remove, the implicit version is fine
            |                ^~~~~~~~
      In file included from /opt/qt515/include/QtCore/QVector:1,
                       from main.cpp:1:
      /opt/qt515/include/QtCore/qvector.h:915:14: warning: implicitly-declared 'constexpr QTypedArrayData<int>::iterator& QTypedArrayData<int>::iterator::operator=(const QTypedArrayData<int>::iterator&)' is deprecated [-Wdeprecated-copy]
        915 |         aend = abegin + itemsToErase;
            |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
      In file included from /opt/qt515/include/QtCore/qvector.h:46,
                       from /opt/qt515/include/QtCore/QVector:1,
                       from main.cpp:1:
      /opt/qt515/include/QtCore/qarraydata.h:144:16: note: because 'QTypedArrayData<int>::iterator' has user-provided 'QTypedArrayData<T>::iterator::iterator(const QTypedArrayData<T>::iterator&) [with T = int]'
        144 |         inline iterator(const iterator &o): i(o.i){} // #### Qt 6: remove, the implicit version is fine
            |                ^~~~~~~~
      

        Attachments

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

          Activity

            People

            Assignee:
            thiago Thiago Macieira
            Reporter:
            hmoffatt Hamish Moffatt
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Gerrit Reviews

                There are no open Gerrit changes