Error inheriting from template with default parameters

Andrey Slepuhin pooh@msu.net
Wed Feb 18 18:37:00 GMT 1998


Hi,

The following (I guess correct) example compiles fine with egcs-980205
on powerpc-ibm-aix4.2.1.0 but gives internal compiler error with both
egcs-980205 and egcs-980214 on i486-pc-linux-gnu.

-------------------------------
template <int S=0, class T=int>
struct X
{};

template <>
struct X<0,int>
{};

template <int S>
struct X<S,int>
: X<>
{};

void main()
{
  X<1,int> x;
}
--------------------------------

Here is gdb output using egcs-980205.
-------------------------------------
$ gdb /usr/local/lib/gcc-lib/i486-pc-linux-gnu/egcs-2.91.07/cc1plus
(gdb) run tmp.ii -quiet -dumpbase tmp.cc -version -o tmp.s
Starting program: /usr/local/lib/gcc-lib/i486-pc-linux-gnu/egcs-2.91.07/cc1plus
tmp.ii -quiet -dumpbase tmp.cc -version -o tmp.s
GNU C++ version egcs-2.91.07 980205 (gcc-2.8.0 release) (i486-pc-linux-gnu)
compiled by GNU C version 2.7.2.3.

Program received signal SIGSEGV, Segmentation fault.
coerce_template_parms (parms=0x8239380, arglist=0x0, in_decl=0x8239628, 
    complain=1, require_all_arguments=1) at pt.c:1754
1754          is_tmpl_parm = TREE_CODE (arglist) == TREE_VEC;
(gdb) bt
#0  coerce_template_parms (parms=0x8239380, arglist=0x0, in_decl=0x8239628, 
    complain=1, require_all_arguments=1) at pt.c:1754
#1  0x8064b20 in lookup_template_class (d1=0x80e8dd0, arglist=0x400d569e, 
    in_decl=0xffffffff, context=0x400d337e) at pt.c:2299
#2  0x40128ce4 in ?? ()
Cannot access memory at address 0x40128ce4.
--------------------------------------------------------------

Replacing ": X<>" to ": X<0,int>" all compiles fine. 

Andrey.




More information about the Gcc-bugs mailing list