https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66897
Bug ID: 66897 Summary: ICE when using remove_reference with type tagged with __may_alias__ Product: gcc Version: 4.9.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: apfokin at gmail dot com Target Milestone: --- I'm using GCC 4.9.2 on Ubuntu 12.04.5, but I've also reproduced this bug on 4.6.3 and 5.1.0. Seems to be a long-standing one. I'm getting an ICE when compiling the following program: template <class _Tp> struct remove_reference {typedef _Tp type;}; template <class _Tp> struct remove_reference<_Tp&> {typedef _Tp type;}; typedef int __attribute__((__may_alias__)) int_a; typedef remove_reference<int&>::type t; typedef remove_reference<int_a&>::type q; int main() { return 0; } This is what g++ -v prints: Using built-in specs. COLLECT_GCC=/base/gcc/bin/g++-4.9 COLLECT_LTO_WRAPPER=/base/gcc/bin/../libexec/gcc/x86_64-unknown-linux-gnu/4.9.2/lto-wrapper Target: x86_64-unknown-linux-gnu Configured with: /base/gcc/src/configure --with-boot-ldflags='-static-libgcc -static-libstdc++' --disable-libstdcxx-pch --prefix=/base/gcc --program-suffix=-4.9 --enable-cloog-backend=isl --enable-languages=c,c++ --enable-__cxa_atexit --disable-nls --disable-multilib --disable-cloog-version-check --enable-build-poststage1-with-cxx --enable-build-with-cxx --disable-gnu-unique-object --with-gmp=/base/output --with-mpfr=/base/output --with-mpc=/base/output --with-isl=/base/output --with-cloog=/base/output --with-ppl=/base/output --with-as=/base/gcc/bin/as --with-ld=/base/gcc/bin/ld --enable-gold=yes Thread model: posix gcc version 4.9.2 (GCC) Command line used to compile the code above: g++ ./test.cpp Compiler output: ./test.cpp: In instantiation of 'struct remove_reference<int&>': ./test.cpp:7:33: required from here ./test.cpp:2:53: internal compiler error: in finish_member_declaration, at cp/semantics.c:2829 template <class _Tp> struct remove_reference<_Tp&> {typedef _Tp type;}; ^ 0x660f70 finish_member_declaration(tree_node*) /base/gcc/src/gcc/cp/semantics.c:2829 0x5e15fd instantiate_class_template_1 /base/gcc/src/gcc/cp/pt.c:9245 0x5e15fd instantiate_class_template(tree_node*) /base/gcc/src/gcc/cp/pt.c:9446 0x637d2d complete_type(tree_node*) /base/gcc/src/gcc/cp/typeck.c:134 0x617ee2 cp_parser_nested_name_specifier_opt /base/gcc/src/gcc/cp/parser.c:5399 0x628bd7 cp_parser_simple_type_specifier /base/gcc/src/gcc/cp/parser.c:14675 0x612385 cp_parser_type_specifier /base/gcc/src/gcc/cp/parser.c:14417 0x623d90 cp_parser_decl_specifier_seq /base/gcc/src/gcc/cp/parser.c:11575 0x631169 cp_parser_simple_declaration /base/gcc/src/gcc/cp/parser.c:11165 0x62b0f3 cp_parser_block_declaration /base/gcc/src/gcc/cp/parser.c:11114 0x6334b2 cp_parser_declaration /base/gcc/src/gcc/cp/parser.c:11011 0x632228 cp_parser_declaration_seq_opt /base/gcc/src/gcc/cp/parser.c:10897 0x633a2a cp_parser_translation_unit /base/gcc/src/gcc/cp/parser.c:4028 0x633a2a c_parse_file() /base/gcc/src/gcc/cp/parser.c:31701 0x6d9d53 c_common_parse_file() /base/gcc/src/gcc/c-family/c-opts.c:1067 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See <http://gcc.gnu.org/bugs.html> for instructions.