https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63139
Bug ID: 63139 Summary: Class-scope typedef overwrites typedef of previously defined class Product: gcc Version: 4.9.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: david.d.kretzmer at gmail dot com In GCC 4.8 and 4.9 (4.7 seems to work correctly) a type alias inside a class seems to overwrite under certain conditions a type alias of the same name in a previously defined class. Code to reproduce this bug: ------------------------------------------------------------ #include <type_traits> template<typename ...T> struct type_list {}; template<typename ...T> struct make_type_list { using type = type_list<T...>; }; // The bug disappears if you use make_type_list directly. template<typename ...T> using make_type_list_t = typename make_type_list<T...>::type; struct ContainerEndA {}; template<typename ...Ts> struct ContainerA { using type = make_type_list_t<Ts..., ContainerEndA>; }; struct ContainerEndB {}; //template<typename Head, typename ...Lists> // If you use this line instead of the next a Internal compiler error is generated. template<typename ...Ts> struct ContainerB { using type = make_type_list_t<Ts..., ContainerEndB>; }; int main() { // To see the types in ContainerA<>::type uncomment the following line. // //ContainerA<>::type::doesnt_exist; // // GCC error: ‘doesnt_exist’ is not a member of ‘ContainerA<>::type {aka type_list<ContainerEndB>}’. // So according to GCC ContainerA<>::type contains ContainerEndB, but it clearly contains only ContainerEndB! static_assert( // It doesn't matter which types you use to instantiate ContainerA and ContainerB std::is_same<ContainerA<int>::type, ContainerB<int>::type>::value, "This assert doesn't fail but it clearly should!" ); } ------------------------------------------------------------ I have tried to minimize the code further but any time I remove something the bug disappears.