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

            Bug ID: 71450
           Summary: ICE on invalid C++11 code on x86_64-linux-gnu: in tree
                    check: expected record_type or union_type or
                    qual_union_type, have template_type_parm in
                    lookup_base, at cp/search.c:203
           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 code causes an ICE when compiled with the current gcc trunk on
x86_64-linux-gnu in both 32-bit and 64-bit modes.

This is a regression from 6.1.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 20160607 (experimental) [trunk revision 237165] (GCC)
$
$ g++-6.1 small.cpp
small.cpp: In instantiation of ‘void g(T) [with T = A]’:
small.cpp:18:10:   required from here
small.cpp:12:14: error: use of ‘x’ before deduction of ‘auto’
   auto x = t + x;
            ~~^~~
small.cpp:12:14: error: no match for ‘operator+’ (operand types are ‘A’ and
‘auto’)
small.cpp:3:5: note: candidate: A A::operator+(A)
   A operator+ (A a)
     ^~~~~~~~
small.cpp:3:5: note:   no known conversion for argument 1 from ‘auto’ to ‘A’
$
$ g++-trunk small.cpp
small.cpp: In instantiation of ‘void g(T) [with T = A]’:
small.cpp:18:10:   required from here
small.cpp:12:14: error: use of ‘x’ before deduction of ‘auto’
   auto x = t + x;
            ~~^~~
small.cpp:12:14: internal compiler error: tree check: expected record_type or
union_type or qual_union_type, have template_type_parm in lookup_base, at
cp/search.c:203
0x1050d8c tree_check_failed(tree_node const*, char const*, int, char const*,
...)
        ../../gcc-source-trunk/gcc/tree.c:9752
0x80848c tree_check3
        ../../gcc-source-trunk/gcc/tree.h:3070
0x80848c lookup_base(tree_node*, tree_node*, int, base_kind*, int)
        ../../gcc-source-trunk/gcc/cp/search.c:203
0x66e4af build_user_type_conversion_1
        ../../gcc-source-trunk/gcc/cp/call.c:3645
0x66f51a implicit_conversion
        ../../gcc-source-trunk/gcc/cp/call.c:1863
0x6718d4 add_function_candidate
        ../../gcc-source-trunk/gcc/cp/call.c:2138
0x6731b7 add_candidates
        ../../gcc-source-trunk/gcc/cp/call.c:5371
0x67a524 build_new_op_1
        ../../gcc-source-trunk/gcc/cp/call.c:5508
0x67b1be build_new_op(unsigned int, tree_code, int, tree_node*, tree_node*,
tree_node*, tree_node**, int)
        ../../gcc-source-trunk/gcc/cp/call.c:5844
0x7be652 build_x_binary_op(unsigned int, tree_code, tree_node*, tree_code,
tree_node*, tree_code, tree_node**, int)
        ../../gcc-source-trunk/gcc/cp/typeck.c:3891
0x6e1882 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool,
bool)
        ../../gcc-source-trunk/gcc/cp/pt.c:16209
0x6d401f tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
        ../../gcc-source-trunk/gcc/cp/pt.c:15820
0x5d5c5a tsubst_init
        ../../gcc-source-trunk/gcc/cp/pt.c:13857
0x6d7e24 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
        ../../gcc-source-trunk/gcc/cp/pt.c:15224
0x6d5550 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
        ../../gcc-source-trunk/gcc/cp/pt.c:15303
0x6d1f55 instantiate_decl(tree_node*, int, bool)
        ../../gcc-source-trunk/gcc/cp/pt.c:22033
0x71eb12 instantiate_pending_templates(int)
        ../../gcc-source-trunk/gcc/cp/pt.c:22152
0x761bf7 c_parse_final_cleanups()
        ../../gcc-source-trunk/gcc/cp/decl2.c:4600
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
{ 
  A operator+ (A a)
  { 
    return a;
  }
};

template < class T >
void g (T t)
{ 
  auto x = t + x;
}

int
main ()
{ 
  g (A ());
  return 0;
}

Reply via email to