[Bug libstdc++/55993] tuple_cat not a constant expression for result size >= 3

jnapoli at alum dot mit.edu gcc-bugzilla@gcc.gnu.org
Tue Jan 15 18:44:00 GMT 2013


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55993

--- Comment #3 from Joshua Napoli <jnapoli at alum dot mit.edu> 2013-01-15 18:44:10 UTC ---
The problem has to do with a completely empty struct being used twice
consecutively in the tuple type list. std::tuple<A,A> inherits from A (by
inheriting _Head_base<A> which inherits A). Maybe there is a problem with
confusing the inherited types when struct A is empty and the base A might not
have a separate address from the top-level tuple.



It compiles OK when I add a member variable:

struct A { constexpr A() : x(0) {} int x; };
constexpr std::tuple<A,A> t;
constexpr auto a = decltype(t)::_M_head(t);



But fails without it:

struct A { constexpr A() /*: x(0)*/ {} /*int x;*/ };
constexpr std::tuple<A,A> t;
constexpr auto a = decltype(t)::_M_head(t);



It compiles OK when I use two different classes

struct A { constexpr A() {} };
struct B { constexpr B() {} };
constexpr std::tuple<A,B> t;
constexpr auto a = decltype(t)::_M_head(t);



If fails to build with two As and a B:

struct A { constexpr A() {} };
struct B { constexpr B() {} };
constexpr std::tuple<A,A,B> t;
constexpr auto a = decltype(t)::_M_head(t);



(Note that std::get<0>( std::tuple<...> ) returns std::tuple<...>::_M_head(t).)



More information about the Gcc-bugs mailing list