https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71605

            Bug ID: 71605
           Summary: ICE on invalid C++ code (incorrect member access): in
                    pop_binding, at cp/name-lookup.c:368
           Product: gcc
           Version: 7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: su at cs dot ucdavis.edu
  Target Milestone: ---

The following C++ code causes an ICE when compiled with the current GCC trunk
on x86_64-linux-gnu in both 32-bit and 64-bit modes.  

It also affects 4.8.x and later, and is a regression from 4.7.x. 


$ g++-trunk -v
Using built-in specs.
COLLECT_GCC=g++-trunk
COLLECT_LTO_WRAPPER=/usr/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/7.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-source-trunk/configure --enable-languages=c,c++,lto
--prefix=/usr/local/gcc-trunk --disable-bootstrap
Thread model: posix
gcc version 7.0.0 20160620 (experimental) [trunk revision 237606] (GCC) 
$ 
$ g++-trunk -c small.cpp
small.cpp: In function ‘void foo()’:
small.cpp:11:4: error: ‘operator I’ is not a member of ‘B’
   &B::operator struct I; // should be: &B::operator struct A;
    ^
small.cpp:11:24: internal compiler error: in pop_binding, at
cp/name-lookup.c:368
   &B::operator struct I; // should be: &B::operator struct A;
                        ^
0x86b23a pop_binding(tree_node*, tree_node*)
        ../../gcc-source-trunk/gcc/cp/name-lookup.c:368
0x6adf57 poplevel(int, int, int)
        ../../gcc-source-trunk/gcc/cp/decl.c:756
0x80e0e3 do_poplevel(tree_node*)
        ../../gcc-source-trunk/gcc/cp/semantics.c:446
0x812769 finish_compound_stmt(tree_node*)
        ../../gcc-source-trunk/gcc/cp/semantics.c:1408
0x7aad67 cp_parser_compound_statement
        ../../gcc-source-trunk/gcc/cp/parser.c:10760
0x7aaf0f cp_parser_function_body
        ../../gcc-source-trunk/gcc/cp/parser.c:20696
0x7aaf0f cp_parser_ctor_initializer_opt_and_function_body
        ../../gcc-source-trunk/gcc/cp/parser.c:20732
0x7ab9b1 cp_parser_function_definition_after_declarator
        ../../gcc-source-trunk/gcc/cp/parser.c:25415
0x7ac6c5 cp_parser_function_definition_from_specifiers_and_declarator
        ../../gcc-source-trunk/gcc/cp/parser.c:25327
0x7ac6c5 cp_parser_init_declarator
        ../../gcc-source-trunk/gcc/cp/parser.c:18468
0x7aca19 cp_parser_simple_declaration
        ../../gcc-source-trunk/gcc/cp/parser.c:12378
0x7acd21 cp_parser_block_declaration
        ../../gcc-source-trunk/gcc/cp/parser.c:12246
0x7b6100 cp_parser_declaration
        ../../gcc-source-trunk/gcc/cp/parser.c:12143
0x7b4bd4 cp_parser_declaration_seq_opt
        ../../gcc-source-trunk/gcc/cp/parser.c:12022
0x7b4f08 cp_parser_translation_unit
        ../../gcc-source-trunk/gcc/cp/parser.c:4324
0x7b4f08 c_parse_file()
        ../../gcc-source-trunk/gcc/cp/parser.c:37486
0x918e52 c_common_parse_file()
        ../../gcc-source-trunk/gcc/c-family/c-opts.c:1070
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.
$ 


--------------------------------------------------------------


struct A {};

struct B
{
  int I; 
  operator struct A () {  return A ();  };
};

void foo ()
{
  &B::operator struct I; // should be: &B::operator struct A;
}

Reply via email to