[Bug libstdc++/94062] Cannot construct tuple from convertible types
redi at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Mar 19 10:49:50 GMT 2020
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94062
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|WAITING |NEW
--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Reduced:
#include <type_traits>
#include <tuple>
struct Bar1
{
Bar1(const Bar1&) = delete;
Bar1(Bar1&&) = delete;
};
struct Foo1
{
operator Bar1() const;
};
int main()
{
static_assert(std::is_constructible<Bar1, const Foo1&>::value, "");
std::tuple<Bar1> tup{Foo1{}};
}
With -std=gnu++17 this fails inside the tuple(UTypes&&...) constructor:
In file included from 94062.cc:2:
/usr/include/c++/9/tuple: In instantiation of ‘constexpr std::_Head_base<_Idx,
_Head, true>::_Head_base(_UHead&&) [with _UHead = Foo1; long unsigned int _Idx
= 0; _Head = Bar1]’:
/usr/include/c++/9/tuple:349:38: required from here
94062.cc:19:32: in ‘constexpr’ expansion of
‘tup.std::tuple<Bar1>::tuple<Foo1>(Foo1{})’
/usr/include/c++/9/tuple:627:61: in ‘constexpr’ expansion of
‘((std::_Tuple_impl<0, Bar1>*)this)->std::_Tuple_impl<0,
Bar1>::_Tuple_impl<Foo1>((* & std::forward<Foo1>((* & __elements#0))))’
/usr/include/c++/9/tuple:87:35: error: use of deleted function
‘Bar1::Bar1(Bar1&&)’
87 | : _Head(std::forward<_UHead>(__h)) { }
| ^
94062.cc:7:5: note: declared here
7 | Bar1(Bar1&&) = delete;
| ^~~~
Without -std=gnu++17 the is_constructible check is false, so there's no viable
constructor.
It seems unlikely to be a libstdc++ bug when the same libstdc++ code compiles
fine with Clang, but I'll look into it.
More information about the Gcc-bugs
mailing list