https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84866
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> --- #include <type_traits> #include <tuple> // X has trivial copy ctor and nontrivial move ctor struct X { X() = default; X(const X&)=default; X(X&&) {} }; // X needs to be nested to trigger the bug union T1 { X x; }; union S1 { int i; T1 t; }; union T2 { int i; }; // If X is in the top-level of the union, it works fine. union S2 { X x; T2 t; }; // Since X has nontrivial move constructor, it should cause the unions // (S1 and S2) to have deleted move constructor and instead fallback to // use the copy constructor. Since X has a trivial copy constructor, // the unions (S1 and S2) should be copy constructible and // is_move_constructible should be true for S1 and S2. bool MoveConstructible1() { return std::is_move_constructible<S1>(); } bool MoveConstructible2() { return std::is_move_constructible<S2>(); } // However, when actually invoking the copy constructor (move is // deleted), GCC tries to instantiate the union's move constructor // and give error. S1 Move1(S1 s) { return std::move(s); } S2 Move2(S2 s) { return std::move(s); }