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

            Bug ID: 70468
           Summary: ICE on valid code on x86_64-linux-gnu in
                    emit_mem_initializers, at cp/init.c:1109
           Product: gcc
           Version: 6.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 (and
4.8.x and later) on x86_64-linux-gnu in both 32-bit and 64-bit modes.  

This 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/6.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 6.0.0 20160330 (experimental) [trunk revision 234546] (GCC) 
$ 
$ g++-4.7 -c small.cpp
$   
$ g++-trunk -c small.cpp
small.cpp: In instantiation of ‘A< <template-parameter-1-1> >::A() [with
<template-parameter-1-1> = S]’:
small.cpp:22:3:   required from ‘B<T1, T2>& operator<<(B<T1, T2>&, int) [with
T1 = S; T2 = S]’
small.cpp:26:47:   required from here
small.cpp:7:21: internal compiler error: in emit_mem_initializers, at
cp/init.c:1109
   A () : f0 (), f1 () {}
                     ^
0x79de0f emit_mem_initializers(tree_node*)
        ../../gcc-source-trunk/gcc/cp/init.c:1109
0x681742 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
        ../../gcc-source-trunk/gcc/cp/pt.c:15110
0x67f050 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
        ../../gcc-source-trunk/gcc/cp/pt.c:15290
0x67b6a8 instantiate_decl(tree_node*, int, bool)
        ../../gcc-source-trunk/gcc/cp/pt.c:22013
0x6c7a52 instantiate_pending_templates(int)
        ../../gcc-source-trunk/gcc/cp/pt.c:22132
0x70a3d7 c_parse_final_cleanups()
        ../../gcc-source-trunk/gcc/cp/decl2.c:4599
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 S {}; 

template < typename = S > 
class A 
{
public:
  A () : f0 (), f1 () {}

private:
  typedef A<> f0; 
  int f1;
};

template < typename = S, typename = S > 
class B
{
}; 

template < typename T1, typename T2 > 
B < T1, T2 > &operator<< (B < T1, T2 >&, const int) 
{
  A<> (); 
}

template 
B < S, S > &operator<< (B < S, S >&, const int);

Reply via email to