https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110507

            Bug ID: 110507
           Summary: cannot initialize immovable type in a std::tuple
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: eric.niebler at gmail dot com
  Target Milestone: ---

The following should work since C++17, when C++ got guaranteed copy elision.


#include <tuple>

struct immovable {
  immovable() = default;
  immovable(immovable&&) = delete;
};

struct init_immovable {
  operator immovable() const { return {}; }
};

int main() {
  std::tuple<immovable> m{init_immovable{}};
}


result:

In file included from <source>:1:
/opt/compiler-explorer/gcc-trunk-20230630/include/c++/14.0.0/tuple: In
instantiation of 'constexpr std::_Head_base<_Idx, _Head,
true>::_Head_base(_UHead&&) [with _UHead = init_immovable; long unsigned int
_Idx = 0; _Head = immovable]':
/opt/compiler-explorer/gcc-trunk-20230630/include/c++/14.0.0/tuple:514:38:  
required from here
<source>:13:43:   in 'constexpr' expansion of
'm.std::tuple<immovable>::tuple<init_immovable>(init_immovable())'
/opt/compiler-explorer/gcc-trunk-20230630/include/c++/14.0.0/tuple:891:54:   in
'constexpr' expansion of '((std::_Tuple_impl<0,
immovable>*)this)->std::_Tuple_impl<0,
immovable>::_Tuple_impl<init_immovable>((* & std::forward<init_immovable>((* &
__elements#0))))'
/opt/compiler-explorer/gcc-trunk-20230630/include/c++/14.0.0/tuple:92:11:
error: use of deleted function 'immovable::immovable(immovable&&)'
   92 |         : _M_head_impl(std::forward<_UHead>(__h)) { }
      |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<source>:5:3: note: declared here
    5 |   immovable(immovable&&) = delete;
      |   ^~~~~~~~~


https://godbolt.org/z/nfd1zdcqs

Reply via email to