[Interest] use of deleted function errors in QList / qarraydataops.h

Hamish Moffatt hamish at risingsoftware.com
Mon Feb 27 08:24:43 CET 2023


I have some code which boils down to this:


#include <QVector>

void test()

{

     struct S

     {

         const QVector<int> v; // compiles if not const

     };

     QVector<std::pair<S, S>> pv; // doesn't compile with this

     //std::vector<std::pair<S, S>> pv; // compiles with this

     pv.push_back(std::make_pair<S, S>({}, {}));

}


This compiles in Qt 5.15.12, but not in 6.4.2.

The last line generates no less than 4 errors, resulting in pages and 
pages of output, but essentially:

../../dev/Qt6.4.2/6.4.2/gcc_64/include/QtCore/qarraydataops.h:472:29: error: use of deleted function ‘std::pair<test()::S, test()::S>& std::pair<test()::S, test()::S>::operator=(const std::pair<test()::S, test()::S>&)’
   472 |                     last[i] = std::move(last[i - 1]);
       |                     ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
--
../../dev/Qt6.4.2/6.4.2/gcc_64/include/QtCore/qarraydataops.h:475:24: error: use of deleted function ‘std::pair<test()::S, test()::S>& std::pair<test()::S, test()::S>::operator=(const std::pair<test()::S, test()::S>&)’
   475 |                 *where = std::move(t);
       |                 ~~~~~~~^~~~~~~~~~~~~~
--
../../dev/Qt6.4.2/6.4.2/gcc_64/include/QtCore/qcontainertools_impl.h:132:18: error: use of deleted function ‘std::pair<test()::S, test()::S>& std::pair<test()::S, test()::S>::operator=(const std::pair<test()::S, test()::S>&)’
   132 |         *d_first = std::move_if_noexcept(*first);
       |         ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--
../../dev/Qt6.4.2/6.4.2/gcc_64/include/QtCore/qcontainertools_impl.h:132:18: error: use of deleted function ‘std::pair<test()::S, test()::S>& std::pair<test()::S, test()::S>::operator=(const std::pair<test()::S, test()::S>&)’


As per the comments, it compiles if the member variable in the inner 
struct is not const, or if I use a std::vector instead of QVector.

Is there a solution?

Full error text below.


Hamish




In file included from ../../dev/Qt6.4.2/6.4.2/gcc_64/include/QtCore/qarraydatapointer.h:7,

                  from ../../dev/Qt6.4.2/6.4.2/gcc_64/include/QtCore/qlist.h:8,

                  from ../../dev/Qt6.4.2/6.4.2/gcc_64/include/QtCore/qvector.h:7,

                  from ../../dev/Qt6.4.2/6.4.2/gcc_64/include/QtCore/QVector:1,

                  from test.cc:1:

../../dev/Qt6.4.2/6.4.2/gcc_64/include/QtCore/qarraydataops.h: In instantiation of ‘void QtPrivate::QGenericArrayOps<T>::Inserter::insertOne(qsizetype, T&&) [with T = std::pair<test()::S, test()::S>; qsizetype = long long int]’:

../../dev/Qt6.4.2/6.4.2/gcc_64/include/QtCore/qarraydataops.h:557:37:   required from ‘void QtPrivate::QGenericArrayOps<T>::emplace(qsizetype, Args&& ...) [with Args = {std::pair<test()::S, test()::S>}; T = std::pair<test()::S, test()::S>; qsizetype = long long int]’

../../dev/Qt6.4.2/6.4.2/gcc_64/include/QtCore/qlist.h:852:15:   required from ‘T& QList<T>::emplaceBack(Args&& ...) [with Args = {std::pair<test()::S, test()::S>}; T = std::pair<test()::S, test()::S>; QList<T>::reference = std::pair<test()::S, test()::S>&]’

../../dev/Qt6.4.2/6.4.2/gcc_64/include/QtCore/qlist.h:440:24:   required from ‘void QList<T>::append(QList<T>::rvalue_ref) [with T = std::pair<test()::S, test()::S>; QList<T>::rvalue_ref = std::pair<test()::S, test()::S>&&]’

../../dev/Qt6.4.2/6.4.2/gcc_64/include/QtCore/qlist.h:652:42:   required from ‘void QList<T>::push_back(QList<T>::rvalue_ref) [with T = std::pair<test()::S, test()::S>; QList<T>::rvalue_ref = std::pair<test()::S, test()::S>&&]’

test.cc:13:43:   required from here

../../dev/Qt6.4.2/6.4.2/gcc_64/include/QtCore/qarraydataops.h:472:29: error: use of deleted function ‘std::pair<test()::S, test()::S>& std::pair<test()::S, test()::S>::operator=(const std::pair<test()::S, test()::S>&)’

   472 |                     last[i] = std::move(last[i - 1]);

       |                     ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~

In file included from /usr/include/c++/10/utility:70,

                  from ../../dev/Qt6.4.2/6.4.2/gcc_64/include/QtCore/qglobal.h:11,

                  from ../../dev/Qt6.4.2/6.4.2/gcc_64/include/QtCore/qpair.h:7,

                  from ../../dev/Qt6.4.2/6.4.2/gcc_64/include/QtCore/qarraydata.h:8,

                  from ../../dev/Qt6.4.2/6.4.2/gcc_64/include/QtCore/qarraydataops.h:8,

                  from ../../dev/Qt6.4.2/6.4.2/gcc_64/include/QtCore/qarraydatapointer.h:7,

                  from ../../dev/Qt6.4.2/6.4.2/gcc_64/include/QtCore/qlist.h:8,

                  from ../../dev/Qt6.4.2/6.4.2/gcc_64/include/QtCore/qvector.h:7,

                  from ../../dev/Qt6.4.2/6.4.2/gcc_64/include/QtCore/QVector:1,

                  from test.cc:1:

/usr/include/c++/10/bits/stl_pair.h:211:12: note: ‘std::pair<test()::S, test()::S>& std::pair<test()::S, test()::S>::operator=(const std::pair<test()::S, test()::S>&)’ is implicitly declared as deleted because ‘std::pair<test()::S, test()::S>’ declares a move constructor or move assignment operator

   211 |     struct pair

       |            ^~~~

In file included from ../../dev/Qt6.4.2/6.4.2/gcc_64/include/QtCore/qarraydatapointer.h:7,

                  from ../../dev/Qt6.4.2/6.4.2/gcc_64/include/QtCore/qlist.h:8,

                  from ../../dev/Qt6.4.2/6.4.2/gcc_64/include/QtCore/qvector.h:7,

                  from ../../dev/Qt6.4.2/6.4.2/gcc_64/include/QtCore/QVector:1,

                  from test.cc:1:

../../dev/Qt6.4.2/6.4.2/gcc_64/include/QtCore/qarraydataops.h:475:24: error: use of deleted function ‘std::pair<test()::S, test()::S>& std::pair<test()::S, test()::S>::operator=(const std::pair<test()::S, test()::S>&)’

   475 |                 *where = std::move(t);

       |                 ~~~~~~~^~~~~~~~~~~~~~

In file included from ../../dev/Qt6.4.2/6.4.2/gcc_64/include/QtCore/qarraydataops.h:9,

                  from ../../dev/Qt6.4.2/6.4.2/gcc_64/include/QtCore/qarraydatapointer.h:7,

                  from ../../dev/Qt6.4.2/6.4.2/gcc_64/include/QtCore/qlist.h:8,

                  from ../../dev/Qt6.4.2/6.4.2/gcc_64/include/QtCore/qvector.h:7,

                  from ../../dev/Qt6.4.2/6.4.2/gcc_64/include/QtCore/QVector:1,

                  from test.cc:1:

../../dev/Qt6.4.2/6.4.2/gcc_64/include/QtCore/qcontainertools_impl.h: In instantiation of ‘void QtPrivate::q_relocate_overlap_n_left_move(iterator, N, iterator) [with iterator = std::pair<test()::S, test()::S>*; N = long long int]’:

../../dev/Qt6.4.2/6.4.2/gcc_64/include/QtCore/qcontainertools_impl.h:167:43:   required from ‘void QtPrivate::q_relocate_overlap_n(T*, N, T*) [with T = std::pair<test()::S, test()::S>; N = long long int]’

../../dev/Qt6.4.2/6.4.2/gcc_64/include/QtCore/qarraydatapointer.h:301:40:   required from ‘void QArrayDataPointer<T>::relocate(qsizetype, const T**) [with T = std::pair<test()::S, test()::S>; qsizetype = long long int]’

../../dev/Qt6.4.2/6.4.2/gcc_64/include/QtCore/qarraydatapointer.h:286:9:   required from ‘bool QArrayDataPointer<T>::tryReadjustFreeSpace(QArrayData::GrowthPosition, qsizetype, const T**) [with T = std::pair<test()::S, test()::S>; qsizetype = long long int]’

../../dev/Qt6.4.2/6.4.2/gcc_64/include/QtCore/qarraydatapointer.h:187:26:   required from ‘void QArrayDataPointer<T>::detachAndGrow(QArrayData::GrowthPosition, qsizetype, const T**, QArrayDataPointer<T>*) [with T = std::pair<test()::S, test()::S>; qsizetype = long long int]’

../../dev/Qt6.4.2/6.4.2/gcc_64/include/QtCore/qarraydataops.h:549:28:   required from ‘void QtPrivate::QGenericArrayOps<T>::emplace(qsizetype, Args&& ...) [with Args = {std::pair<test()::S, test()::S>}; T = std::pair<test()::S, test()::S>; qsizetype = long long int]’

../../dev/Qt6.4.2/6.4.2/gcc_64/include/QtCore/qlist.h:852:15:   required from ‘T& QList<T>::emplaceBack(Args&& ...) [with Args = {std::pair<test()::S, test()::S>}; T = std::pair<test()::S, test()::S>; QList<T>::reference = std::pair<test()::S, test()::S>&]’

../../dev/Qt6.4.2/6.4.2/gcc_64/include/QtCore/qlist.h:440:24:   required from ‘void QList<T>::append(QList<T>::rvalue_ref) [with T = std::pair<test()::S, test()::S>; QList<T>::rvalue_ref = std::pair<test()::S, test()::S>&&]’

../../dev/Qt6.4.2/6.4.2/gcc_64/include/QtCore/qlist.h:652:42:   required from ‘void QList<T>::push_back(QList<T>::rvalue_ref) [with T = std::pair<test()::S, test()::S>; QList<T>::rvalue_ref = std::pair<test()::S, test()::S>&&]’

test.cc:13:43:   required from here

../../dev/Qt6.4.2/6.4.2/gcc_64/include/QtCore/qcontainertools_impl.h:132:18: error: use of deleted function ‘std::pair<test()::S, test()::S>& std::pair<test()::S, test()::S>::operator=(const std::pair<test()::S, test()::S>&)’

   132 |         *d_first = std::move_if_noexcept(*first);

       |         ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

../../dev/Qt6.4.2/6.4.2/gcc_64/include/QtCore/qcontainertools_impl.h: In instantiation of ‘void QtPrivate::q_relocate_overlap_n_left_move(iterator, N, iterator) [with iterator = std::reverse_iterator<std::pair<test()::S, test()::S>*>; N = long long int]’:

../../dev/Qt6.4.2/6.4.2/gcc_64/include/QtCore/qcontainertools_impl.h:171:43:   required from ‘void QtPrivate::q_relocate_overlap_n(T*, N, T*) [with T = std::pair<test()::S, test()::S>; N = long long int]’

../../dev/Qt6.4.2/6.4.2/gcc_64/include/QtCore/qarraydatapointer.h:301:40:   required from ‘void QArrayDataPointer<T>::relocate(qsizetype, const T**) [with T = std::pair<test()::S, test()::S>; qsizetype = long long int]’

../../dev/Qt6.4.2/6.4.2/gcc_64/include/QtCore/qarraydatapointer.h:286:9:   required from ‘bool QArrayDataPointer<T>::tryReadjustFreeSpace(QArrayData::GrowthPosition, qsizetype, const T**) [with T = std::pair<test()::S, test()::S>; qsizetype = long long int]’

../../dev/Qt6.4.2/6.4.2/gcc_64/include/QtCore/qarraydatapointer.h:187:26:   required from ‘void QArrayDataPointer<T>::detachAndGrow(QArrayData::GrowthPosition, qsizetype, const T**, QArrayDataPointer<T>*) [with T = std::pair<test()::S, test()::S>; qsizetype = long long int]’

../../dev/Qt6.4.2/6.4.2/gcc_64/include/QtCore/qarraydataops.h:549:28:   required from ‘void QtPrivate::QGenericArrayOps<T>::emplace(qsizetype, Args&& ...) [with Args = {std::pair<test()::S, test()::S>}; T = std::pair<test()::S, test()::S>; qsizetype = long long int]’

../../dev/Qt6.4.2/6.4.2/gcc_64/include/QtCore/qlist.h:852:15:   required from ‘T& QList<T>::emplaceBack(Args&& ...) [with Args = {std::pair<test()::S, test()::S>}; T = std::pair<test()::S, test()::S>; QList<T>::reference = std::pair<test()::S, test()::S>&]’

../../dev/Qt6.4.2/6.4.2/gcc_64/include/QtCore/qlist.h:440:24:   required from ‘void QList<T>::append(QList<T>::rvalue_ref) [with T = std::pair<test()::S, test()::S>; QList<T>::rvalue_ref = std::pair<test()::S, test()::S>&&]’

../../dev/Qt6.4.2/6.4.2/gcc_64/include/QtCore/qlist.h:652:42:   required from ‘void QList<T>::push_back(QList<T>::rvalue_ref) [with T = std::pair<test()::S, test()::S>; QList<T>::rvalue_ref = std::pair<test()::S, test()::S>&&]’

test.cc:13:43:   required from here

../../dev/Qt6.4.2/6.4.2/gcc_64/include/QtCore/qcontainertools_impl.h:132:18: error: use of deleted function ‘std::pair<test()::S, test()::S>& std::pair<test()::S, test()::S>::operator=(const std::pair<test()::S, test()::S>&)’

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20230227/4651e169/attachment.htm>


More information about the Interest mailing list