Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error: static assertion failed: result type must be constructible from input type when building with -DQT6=ON #11167

Closed
Holzhaus opened this issue Dec 30, 2022 · 11 comments · Fixed by #11180

Comments

@Holzhaus
Copy link
Member

Bug Description

I cannot build mixxx with -DQT6=ON due to this error:

In file included from /usr/include/c++/12.2.0/memory:66,
                 from /usr/include/qt6/QtCore/qcontainertools_impl.h:19,
                 from /usr/include/qt6/QtCore/qarraydataops.h:9,
                 from /usr/include/qt6/QtCore/qarraydatapointer.h:7,
                 from /usr/include/qt6/QtCore/qlist.h:8,
                 from /usr/include/qt6/QtCore/qmap.h:9,
                 from /usr/include/qt6/QtCore/QMap:1,
                 from /home/jan/Projects/mixxx/src/effects/backends/builtin/autopaneffect.h:3,
                 from /home/jan/Projects/mixxx/src/effects/backends/builtin/autopaneffect.cpp:1:
/usr/include/c++/12.2.0/bits/stl_uninitialized.h: In instantiation of ‘constexpr bool std::__check_constructible() [with _ValueType = unique_ptr<AutoPanGroupState, default_delete<AutoPanGroupState> >; _Tp = const unique_ptr<AutoPanGroupState, default_delete<AutoPanGroupState> >&]’:
/usr/include/c++/12.2.0/bits/stl_uninitialized.h:182:4:   required from ‘_ForwardIterator std::uninitialized_copy(_InputIterator, _InputIterator, _ForwardIterator) [with _InputIterator = __gnu_cxx::__normal_iterator<const unique_ptr<AutoPanGroupState, default_delete<AutoPanGroupState> >*, vector<unique_ptr<AutoPanGroupState, default_delete<AutoPanGroupState> >, allocator<unique_ptr<AutoPanGroupState, default_delete<AutoPanGroupState> > > > >; _ForwardIterator = unique_ptr<AutoPanGroupState, default_delete<AutoPanGroupState> >*]’
/usr/include/c++/12.2.0/bits/stl_uninitialized.h:372:37:   required from ‘constexpr _ForwardIterator std::__uninitialized_copy_a(_InputIterator, _InputIterator, _ForwardIterator, allocator<_Tp>&) [with _InputIterator = __gnu_cxx::__normal_iterator<const unique_ptr<AutoPanGroupState, default_delete<AutoPanGroupState> >*, vector<unique_ptr<AutoPanGroupState, default_delete<AutoPanGroupState> >, allocator<unique_ptr<AutoPanGroupState, default_delete<AutoPanGroupState> > > > >; _ForwardIterator = unique_ptr<AutoPanGroupState, default_delete<AutoPanGroupState> >*; _Tp = unique_ptr<AutoPanGroupState, default_delete<AutoPanGroupState> >]’
/usr/include/c++/12.2.0/bits/stl_vector.h:601:31:   required from ‘constexpr std::vector<_Tp, _Alloc>::vector(const std::vector<_Tp, _Alloc>&) [with _Tp = std::unique_ptr<AutoPanGroupState, std::default_delete<AutoPanGroupState> >; _Alloc = std::allocator<std::unique_ptr<AutoPanGroupState, std::default_delete<AutoPanGroupState> > >]’
/usr/include/qt6/QtCore/qvarlengtharray.h:754:17:   required from ‘void QVLABase<T>::reallocate_impl(qsizetype, void*, qsizetype, qsizetype, const T*) [with T = std::vector<std::unique_ptr<AutoPanGroupState, std::default_delete<AutoPanGroupState> >, std::allocator<std::unique_ptr<AutoPanGroupState, std::default_delete<AutoPanGroupState> > > >; qsizetype = long long int]’
/usr/include/qt6/QtCore/qvarlengtharray.h:211:7:   required from ‘void QVLABase<T>::resize_impl(qsizetype, void*, qsizetype, const T*) [with T = std::vector<std::unique_ptr<AutoPanGroupState, std::default_delete<AutoPanGroupState> >, std::allocator<std::unique_ptr<AutoPanGroupState, std::default_delete<AutoPanGroupState> > > >; qsizetype = long long int]’
/usr/include/qt6/QtCore/qvarlengtharray.h:376:50:   required from ‘void QVarLengthArray<T, Prealloc>::resize(qsizetype) [with T = std::vector<std::unique_ptr<AutoPanGroupState, std::default_delete<AutoPanGroupState> >, std::allocator<std::unique_ptr<AutoPanGroupState, std::default_delete<AutoPanGroupState> > > >; long long int Prealloc = 256; qsizetype = long long int]’
/home/jan/Projects/mixxx/src/engine/channelhandle.h:245:30:   required from ‘void ChannelHandleMap<T>::maybeExpand(int) [with T = std::vector<std::unique_ptr<AutoPanGroupState, std::default_delete<AutoPanGroupState> >, std::allocator<std::unique_ptr<AutoPanGroupState, std::default_delete<AutoPanGroupState> > > >]’
/home/jan/Projects/mixxx/src/engine/channelhandle.h:208:9:   required from ‘T& ChannelHandleMap<T>::operator[](const ChannelHandle&) [with T = std::vector<std::unique_ptr<AutoPanGroupState, std::default_delete<AutoPanGroupState> >, std::allocator<std::unique_ptr<AutoPanGroupState, std::default_delete<AutoPanGroupState> > > >]’
/home/jan/Projects/mixxx/src/effects/backends/effectprocessor.h:203:57:   required from ‘void EffectProcessorImpl<EffectSpecificState>::initializeInputChannel(ChannelHandle, const mixxx::EngineParameters&) [with EffectSpecificState = AutoPanGroupState]’
/home/jan/Projects/mixxx/src/effects/backends/effectprocessor.h:183:10:   required from here
/usr/include/c++/12.2.0/bits/stl_uninitialized.h:90:56: error: static assertion failed: result type must be constructible from input type
   90 |       static_assert(is_constructible<_ValueType, _Tp>::value,
      |                                                        ^~~~~
/usr/include/c++/12.2.0/bits/stl_uninitialized.h:90:56: note: ‘std::integral_constant<bool, false>::value’ evaluates to false
In file included from /usr/include/c++/12.2.0/variant:45,
                 from /usr/include/qt6/QtCore/qtypeinfo.h:7,
                 from /usr/include/qt6/QtCore/qglobal.h:1397,
                 from /usr/include/qt6/QtCore/qiterator.h:7,
                 from /usr/include/qt6/QtCore/qmap.h:8:
/usr/include/c++/12.2.0/bits/stl_construct.h: In instantiation of ‘constexpr void std::_Construct(_Tp*, _Args&& ...) [with _Tp = unique_ptr<AutoPanGroupState, default_delete<AutoPanGroupState> >; _Args = {const unique_ptr<AutoPanGroupState, default_delete<AutoPanGroupState> >&}]’:
/usr/include/c++/12.2.0/bits/stl_uninitialized.h:120:21:   required from ‘constexpr _ForwardIterator std::__do_uninit_copy(_InputIterator, _InputIterator, _ForwardIterator) [with _InputIterator = __gnu_cxx::__normal_iterator<const unique_ptr<AutoPanGroupState, default_delete<AutoPanGroupState> >*, vector<unique_ptr<AutoPanGroupState, default_delete<AutoPanGroupState> >, allocator<unique_ptr<AutoPanGroupState, default_delete<AutoPanGroupState> > > > >; _ForwardIterator = unique_ptr<AutoPanGroupState, default_delete<AutoPanGroupState> >*]’
/usr/include/c++/12.2.0/bits/stl_uninitialized.h:370:30:   required from ‘constexpr _ForwardIterator std::__uninitialized_copy_a(_InputIterator, _InputIterator, _ForwardIterator, allocator<_Tp>&) [with _InputIterator = __gnu_cxx::__normal_iterator<const unique_ptr<AutoPanGroupState, default_delete<AutoPanGroupState> >*, vector<unique_ptr<AutoPanGroupState, default_delete<AutoPanGroupState> >, allocator<unique_ptr<AutoPanGroupState, default_delete<AutoPanGroupState> > > > >; _ForwardIterator = unique_ptr<AutoPanGroupState, default_delete<AutoPanGroupState> >*; _Tp = unique_ptr<AutoPanGroupState, default_delete<AutoPanGroupState> >]’
/usr/include/c++/12.2.0/bits/stl_vector.h:601:31:   required from ‘constexpr std::vector<_Tp, _Alloc>::vector(const std::vector<_Tp, _Alloc>&) [with _Tp = std::unique_ptr<AutoPanGroupState, std::default_delete<AutoPanGroupState> >; _Alloc = std::allocator<std::unique_ptr<AutoPanGroupState, std::default_delete<AutoPanGroupState> > >]’
/usr/include/qt6/QtCore/qvarlengtharray.h:754:17:   required from ‘void QVLABase<T>::reallocate_impl(qsizetype, void*, qsizetype, qsizetype, const T*) [with T = std::vector<std::unique_ptr<AutoPanGroupState, std::default_delete<AutoPanGroupState> >, std::allocator<std::unique_ptr<AutoPanGroupState, std::default_delete<AutoPanGroupState> > > >; qsizetype = long long int]’
/usr/include/qt6/QtCore/qvarlengtharray.h:211:7:   required from ‘void QVLABase<T>::resize_impl(qsizetype, void*, qsizetype, const T*) [with T = std::vector<std::unique_ptr<AutoPanGroupState, std::default_delete<AutoPanGroupState> >, std::allocator<std::unique_ptr<AutoPanGroupState, std::default_delete<AutoPanGroupState> > > >; qsizetype = long long int]’
/usr/include/qt6/QtCore/qvarlengtharray.h:376:50:   required from ‘void QVarLengthArray<T, Prealloc>::resize(qsizetype) [with T = std::vector<std::unique_ptr<AutoPanGroupState, std::default_delete<AutoPanGroupState> >, std::allocator<std::unique_ptr<AutoPanGroupState, std::default_delete<AutoPanGroupState> > > >; long long int Prealloc = 256; qsizetype = long long int]’
/home/jan/Projects/mixxx/src/engine/channelhandle.h:245:30:   required from ‘void ChannelHandleMap<T>::maybeExpand(int) [with T = std::vector<std::unique_ptr<AutoPanGroupState, std::default_delete<AutoPanGroupState> >, std::allocator<std::unique_ptr<AutoPanGroupState, std::default_delete<AutoPanGroupState> > > >]’
/home/jan/Projects/mixxx/src/engine/channelhandle.h:208:9:   required from ‘T& ChannelHandleMap<T>::operator[](const ChannelHandle&) [with T = std::vector<std::unique_ptr<AutoPanGroupState, std::default_delete<AutoPanGroupState> >, std::allocator<std::unique_ptr<AutoPanGroupState, std::default_delete<AutoPanGroupState> > > >]’
/home/jan/Projects/mixxx/src/effects/backends/effectprocessor.h:203:57:   required from ‘void EffectProcessorImpl<EffectSpecificState>::initializeInputChannel(ChannelHandle, const mixxx::EngineParameters&) [with EffectSpecificState = AutoPanGroupState]’
/home/jan/Projects/mixxx/src/effects/backends/effectprocessor.h:183:10:   required from here
/usr/include/c++/12.2.0/bits/stl_construct.h:115:28: error: no matching function for call to ‘construct_at(std::unique_ptr<AutoPanGroupState, std::default_delete<AutoPanGroupState> >*&, const std::unique_ptr<AutoPanGroupState, std::default_delete<AutoPanGroupState> >&)’
  115 |           std::construct_at(__p, std::forward<_Args>(__args)...);
      |           ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/12.2.0/bits/stl_construct.h:94:5: note: candidate: ‘template<class _Tp, class ... _Args> constexpr decltype (::new(void*(0)) _Tp) std::construct_at(_Tp*, _Args&& ...)’
   94 |     construct_at(_Tp* __location, _Args&&... __args)
      |     ^~~~~~~~~~~~
/usr/include/c++/12.2.0/bits/stl_construct.h:94:5: note:   template argument deduction/substitution failed:
/usr/include/c++/12.2.0/bits/stl_construct.h: In substitution of ‘template<class _Tp, class ... _Args> constexpr decltype (::new(void*(0)) _Tp) std::construct_at(_Tp*, _Args&& ...) [with _Tp = std::unique_ptr<AutoPanGroupState, std::default_delete<AutoPanGroupState> >; _Args = {const std::unique_ptr<AutoPanGroupState, std::default_delete<AutoPanGroupState> >&}]’:
/usr/include/c++/12.2.0/bits/stl_construct.h:115:21:   required from ‘constexpr void std::_Construct(_Tp*, _Args&& ...) [with _Tp = unique_ptr<AutoPanGroupState, default_delete<AutoPanGroupState> >; _Args = {const unique_ptr<AutoPanGroupState, default_delete<AutoPanGroupState> >&}]’
/usr/include/c++/12.2.0/bits/stl_uninitialized.h:120:21:   required from ‘constexpr _ForwardIterator std::__do_uninit_copy(_InputIterator, _InputIterator, _ForwardIterator) [with _InputIterator = __gnu_cxx::__normal_iterator<const unique_ptr<AutoPanGroupState, default_delete<AutoPanGroupState> >*, vector<unique_ptr<AutoPanGroupState, default_delete<AutoPanGroupState> >, allocator<unique_ptr<AutoPanGroupState, default_delete<AutoPanGroupState> > > > >; _ForwardIterator = unique_ptr<AutoPanGroupState, default_delete<AutoPanGroupState> >*]’
/usr/include/c++/12.2.0/bits/stl_uninitialized.h:370:30:   required from ‘constexpr _ForwardIterator std::__uninitialized_copy_a(_InputIterator, _InputIterator, _ForwardIterator, allocator<_Tp>&) [with _InputIterator = __gnu_cxx::__normal_iterator<const unique_ptr<AutoPanGroupState, default_delete<AutoPanGroupState> >*, vector<unique_ptr<AutoPanGroupState, default_delete<AutoPanGroupState> >, allocator<unique_ptr<AutoPanGroupState, default_delete<AutoPanGroupState> > > > >; _ForwardIterator = unique_ptr<AutoPanGroupState, default_delete<AutoPanGroupState> >*; _Tp = unique_ptr<AutoPanGroupState, default_delete<AutoPanGroupState> >]’
/usr/include/c++/12.2.0/bits/stl_vector.h:601:31:   required from ‘constexpr std::vector<_Tp, _Alloc>::vector(const std::vector<_Tp, _Alloc>&) [with _Tp = std::unique_ptr<AutoPanGroupState, std::default_delete<AutoPanGroupState> >; _Alloc = std::allocator<std::unique_ptr<AutoPanGroupState, std::default_delete<AutoPanGroupState> > >]’
/usr/include/qt6/QtCore/qvarlengtharray.h:754:17:   required from ‘void QVLABase<T>::reallocate_impl(qsizetype, void*, qsizetype, qsizetype, const T*) [with T = std::vector<std::unique_ptr<AutoPanGroupState, std::default_delete<AutoPanGroupState> >, std::allocator<std::unique_ptr<AutoPanGroupState, std::default_delete<AutoPanGroupState> > > >; qsizetype = long long int]’
/usr/include/qt6/QtCore/qvarlengtharray.h:211:7:   required from ‘void QVLABase<T>::resize_impl(qsizetype, void*, qsizetype, const T*) [with T = std::vector<std::unique_ptr<AutoPanGroupState, std::default_delete<AutoPanGroupState> >, std::allocator<std::unique_ptr<AutoPanGroupState, std::default_delete<AutoPanGroupState> > > >; qsizetype = long long int]’
/usr/include/qt6/QtCore/qvarlengtharray.h:376:50:   required from ‘void QVarLengthArray<T, Prealloc>::resize(qsizetype) [with T = std::vector<std::unique_ptr<AutoPanGroupState, std::default_delete<AutoPanGroupState> >, std::allocator<std::unique_ptr<AutoPanGroupState, std::default_delete<AutoPanGroupState> > > >; long long int Prealloc = 256; qsizetype = long long int]’
/home/jan/Projects/mixxx/src/engine/channelhandle.h:245:30:   required from ‘void ChannelHandleMap<T>::maybeExpand(int) [with T = std::vector<std::unique_ptr<AutoPanGroupState, std::default_delete<AutoPanGroupState> >, std::allocator<std::unique_ptr<AutoPanGroupState, std::default_delete<AutoPanGroupState> > > >]’
/home/jan/Projects/mixxx/src/engine/channelhandle.h:208:9:   required from ‘T& ChannelHandleMap<T>::operator[](const ChannelHandle&) [with T = std::vector<std::unique_ptr<AutoPanGroupState, std::default_delete<AutoPanGroupState> >, std::allocator<std::unique_ptr<AutoPanGroupState, std::default_delete<AutoPanGroupState> > > >]’
/home/jan/Projects/mixxx/src/effects/backends/effectprocessor.h:203:57:   required from ‘void EffectProcessorImpl<EffectSpecificState>::initializeInputChannel(ChannelHandle, const mixxx::EngineParameters&) [with EffectSpecificState = AutoPanGroupState]’
/home/jan/Projects/mixxx/src/effects/backends/effectprocessor.h:183:10:   required from here
/usr/include/c++/12.2.0/bits/stl_construct.h:96:17: error: use of deleted function ‘std::unique_ptr<_Tp, _Dp>::unique_ptr(const std::unique_ptr<_Tp, _Dp>&) [with _Tp = AutoPanGroupState; _Dp = std::default_delete<AutoPanGroupState>]’
   96 |     -> decltype(::new((void*)0) _Tp(std::declval<_Args>()...))
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/12.2.0/memory:76:
/usr/include/c++/12.2.0/bits/unique_ptr.h:514:7: note: declared here
  514 |       unique_ptr(const unique_ptr&) = delete;
      |       ^~~~~~~~~~
/usr/include/c++/12.2.0/bits/stl_construct.h: In instantiation of ‘constexpr void std::_Construct(_Tp*, _Args&& ...) [with _Tp = unique_ptr<AutoPanGroupState, default_delete<AutoPanGroupState> >; _Args = {const unique_ptr<AutoPanGroupState, default_delete<AutoPanGroupState> >&}]’:
/usr/include/c++/12.2.0/bits/stl_uninitialized.h:120:21:   required from ‘constexpr _ForwardIterator std::__do_uninit_copy(_InputIterator, _InputIterator, _ForwardIterator) [with _InputIterator = __gnu_cxx::__normal_iterator<const unique_ptr<AutoPanGroupState, default_delete<AutoPanGroupState> >*, vector<unique_ptr<AutoPanGroupState, default_delete<AutoPanGroupState> >, allocator<unique_ptr<AutoPanGroupState, default_delete<AutoPanGroupState> > > > >; _ForwardIterator = unique_ptr<AutoPanGroupState, default_delete<AutoPanGroupState> >*]’
/usr/include/c++/12.2.0/bits/stl_uninitialized.h:370:30:   required from ‘constexpr _ForwardIterator std::__uninitialized_copy_a(_InputIterator, _InputIterator, _ForwardIterator, allocator<_Tp>&) [with _InputIterator = __gnu_cxx::__normal_iterator<const unique_ptr<AutoPanGroupState, default_delete<AutoPanGroupState> >*, vector<unique_ptr<AutoPanGroupState, default_delete<AutoPanGroupState> >, allocator<unique_ptr<AutoPanGroupState, default_delete<AutoPanGroupState> > > > >; _ForwardIterator = unique_ptr<AutoPanGroupState, default_delete<AutoPanGroupState> >*; _Tp = unique_ptr<AutoPanGroupState, default_delete<AutoPanGroupState> >]’
/usr/include/c++/12.2.0/bits/stl_vector.h:601:31:   required from ‘constexpr std::vector<_Tp, _Alloc>::vector(const std::vector<_Tp, _Alloc>&) [with _Tp = std::unique_ptr<AutoPanGroupState, std::default_delete<AutoPanGroupState> >; _Alloc = std::allocator<std::unique_ptr<AutoPanGroupState, std::default_delete<AutoPanGroupState> > >]’
/usr/include/qt6/QtCore/qvarlengtharray.h:754:17:   required from ‘void QVLABase<T>::reallocate_impl(qsizetype, void*, qsizetype, qsizetype, const T*) [with T = std::vector<std::unique_ptr<AutoPanGroupState, std::default_delete<AutoPanGroupState> >, std::allocator<std::unique_ptr<AutoPanGroupState, std::default_delete<AutoPanGroupState> > > >; qsizetype = long long int]’
/usr/include/qt6/QtCore/qvarlengtharray.h:211:7:   required from ‘void QVLABase<T>::resize_impl(qsizetype, void*, qsizetype, const T*) [with T = std::vector<std::unique_ptr<AutoPanGroupState, std::default_delete<AutoPanGroupState> >, std::allocator<std::unique_ptr<AutoPanGroupState, std::default_delete<AutoPanGroupState> > > >; qsizetype = long long int]’
/usr/include/qt6/QtCore/qvarlengtharray.h:376:50:   required from ‘void QVarLengthArray<T, Prealloc>::resize(qsizetype) [with T = std::vector<std::unique_ptr<AutoPanGroupState, std::default_delete<AutoPanGroupState> >, std::allocator<std::unique_ptr<AutoPanGroupState, std::default_delete<AutoPanGroupState> > > >; long long int Prealloc = 256; qsizetype = long long int]’
/home/jan/Projects/mixxx/src/engine/channelhandle.h:245:30:   required from ‘void ChannelHandleMap<T>::maybeExpand(int) [with T = std::vector<std::unique_ptr<AutoPanGroupState, std::default_delete<AutoPanGroupState> >, std::allocator<std::unique_ptr<AutoPanGroupState, std::default_delete<AutoPanGroupState> > > >]’
/home/jan/Projects/mixxx/src/engine/channelhandle.h:208:9:   required from ‘T& ChannelHandleMap<T>::operator[](const ChannelHandle&) [with T = std::vector<std::unique_ptr<AutoPanGroupState, std::default_delete<AutoPanGroupState> >, std::allocator<std::unique_ptr<AutoPanGroupState, std::default_delete<AutoPanGroupState> > > >]’
/home/jan/Projects/mixxx/src/effects/backends/effectprocessor.h:203:57:   required from ‘void EffectProcessorImpl<EffectSpecificState>::initializeInputChannel(ChannelHandle, const mixxx::EngineParameters&) [with EffectSpecificState = AutoPanGroupState]’
/home/jan/Projects/mixxx/src/effects/backends/effectprocessor.h:183:10:   required from here
/usr/include/c++/12.2.0/bits/stl_construct.h:119:7: error: use of deleted function ‘std::unique_ptr<_Tp, _Dp>::unique_ptr(const std::unique_ptr<_Tp, _Dp>&) [with _Tp = AutoPanGroupState; _Dp = std::default_delete<AutoPanGroupState>]’
  119 |       ::new((void*)__p) _Tp(std::forward<_Args>(__args)...);
      |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/12.2.0/bits/unique_ptr.h:514:7: note: declared here
  514 |       unique_ptr(const unique_ptr&) = delete;
      |       ^~~~~~~~~~
make[2]: *** [CMakeFiles/mixxx-lib.dir/build.make:1462: CMakeFiles/mixxx-lib.dir/src/effects/backends/builtin/autopaneffect.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:298: CMakeFiles/mixxx-lib.dir/all] Error 2
make: *** [Makefile:166: all] Error 2

IIUC the issue is that it tries to make a copy of the unique_ptr when accessing the ChannelHandleMap<std::vector<std::unique_ptr<EffectSpecificState>>>:

auto& outputChannelStates = m_channelStateMatrix[inputChannel];

Version

Latest main (86a280b)

OS

Arch Linux with gcc 12.2.0-1 on AMD64

@Holzhaus Holzhaus added the bug label Dec 30, 2022
@Swiftb0y
Copy link
Member

Swiftb0y commented Dec 31, 2022

I think the problem in particular is that the ChannelHandleMap<T>::operator[] might resize and for some reason it resizes by copying the contained vector<unique_ptr> instead of moving. IMO this is a Qt bug (I don't see why it shouldn't be possible to move instead of copy).
Also std::map requires that the map value is CopyConstructible, so the QMap requirements are already laxer than the ones from the standard.
Why are we using a std::vector<unique_ptr<EffectSpecificState>> anyways? Is there any benefit gained from the indirection? Can't we just make it std::vector<EffectSpecificState>?

@daschuer
Copy link
Member

daschuer commented Jan 2, 2023

I think we hit a bug introduced in Qt 6.4.0:

It fails here:
https://github.com/qt/qtbase/blob/067b53864112c084587fa9a507eb4bde3d50a6e1/src/corelib/tools/qvarlengtharray.h#L754
The code has been introduced here:
qt/qtbase@a00a1d8#diff-3f4287973382b16af82c02e80740e5efbb0e5753771a19d6309eb2f7f6f6cd6d

Even though the code of question is not used, it is compiled and fails:
if constexpr (std::is_copy_constructible_v<T>) {

becomes
if constexpr (std::is_copy_constructible_v<std::vector<std::unique_ptr<EffectSpecificState>>>>) {
which is true
but the subsequent
static_assert(is_constructible<std::unique_ptr<EffectSpecificState>...
is false.

See also:
https://godbolt.org/z/948xd73xT

I will report a QT bug.

@daschuer
Copy link
Member

daschuer commented Jan 2, 2023

@Swiftb0y
Copy link
Member

Swiftb0y commented Jan 2, 2023

Thanks for your further research and filing the Qt bug, seems like they're taking it seriously. Conversely, I'm wondering why static_assert(std::is_copy_constructible_v<std::vector<std::unique_ptr<int>>>); compiles even though copying such a vector (fortunately) doesn't work: https://godbolt.org/z/fWPKsh7f8

@daschuer
Copy link
Member

daschuer commented Jan 2, 2023

This is a workaround.
#11180

I also had a look into the idea to hold a copy by value but that is difficult because we don't know the effect setup at compile time.

@Swiftb0y
Copy link
Member

Swiftb0y commented Jan 3, 2023

I also had a look into the idea to hold a copy by value but that is difficult because we don't know the effect setup at compile time.

Can you elaborate? EffectSpecificState is a template parameter for a concrete type, there is no runtime type-erasure that would require indirection.

@daschuer
Copy link
Member

daschuer commented Jan 3, 2023

The effect specific state is created dynamically according to the registered channels. That's why I think we need a container class.
It is cheaper to fill the container with pointers instead of copy or move the whole object.

@Swiftb0y
Copy link
Member

Swiftb0y commented Jan 3, 2023

Ah I see, good point... making the entire thing a std::vector<std::optional<EffectSpecificState>> ain't great either because that probably results in a bunch of wasted space.

@marcmutz
Copy link

marcmutz commented Jan 3, 2023

An instance of the problem described here: https://quuxplusone.github.io/blog/2020/02/05/vector-is-copyable-except-when-its-not/ I'll see what I can do. As a work-around,wrap the vector:

 template <typename T, typename .... Args>
 struct moveonly_vector : std::vector<T, Args...>
 {
     using base = std::vector<T, Args...>;
     using base::base;
     moveonly_vector(moveonly_vector &&) = default;
     moveonly_vector &operator=(moveonly_vector &&) = default; 
     moveonly_vector(const moveonly_vector &&) = delete;
     moveonly_vector &operator=(moveonly_vector &&) = delete;
}; 

QVarLengthArray<moveonly_vector<std::unique_ptr<~~~>>> fixed;

@daschuer
Copy link
Member

daschuer commented Jan 3, 2023

Thank you for coming back to us. This is almost the same we have implemented in #11180

@daschuer
Copy link
Member

The upstream bug has been fixed here:
qt/qtbase@89672ef

@Swiftb0y Swiftb0y added this to Qt6 May 28, 2024
@Swiftb0y Swiftb0y moved this to Done in Qt6 May 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

4 participants