Lack of prototype leads to Internal Compiler Error
Iain McClatchie
iain@mcclatchie.com
Fri Sep 4 15:42:00 GMT 1998
BAD: We get an Internal Compiler Error
OKAY: We fail on (only slightly) illegal C++ code
GOOD: There is a workaround
WORRISOME: It looks like the real problem is in parsing legal C++ code.
The problem exists in egcs-1.0.3 and egcs-1.1a. I have not checked
other compiler revisions.
[iain@gw1 ~/svs]$ /usr/local/bin/gcc -c test.cc
test.cc: In function `void sort<inst_list_t>(class inst_list_t *&, int
(*)(const class inst_list_t **, const class inst_list_t **) = compare)':
test.cc:50: instantiated from here
test.cc:36: Internal compiler error.
test.cc:36: Please submit a full bug report to `egcs-bugs@cygnus.com'.
[iain@gw1 ~/svs]$ /usr/local/bin/gcc -c -DOKAY test.cc
[iain@gw1 ~/svs]$
The difference between these two compiles is that with -DOKAY, I've
got a prototype for the qsort function. While I was paring down this
test case, I noticed a few other error messages saying something about
unrecognised tree codes, so I suspect there is some problem with the
RTL generated by the parser on the definition of sort().
test.cc:21: sorry, not implemented: initializer contains unrecognized
tree code
test.cc:22: sorry, not implemented: initializer contains unrecognized
tree code
test.cc:24: sorry, not implemented: initializer contains unrecognized
tree code
Here's the test case:
template <class elem_t>
class list {
public:
typedef list<elem_t> list_t;
list_t *next;
elem_t e;
inline int length( ) const;
};
#ifdef OKAY
void
qsort(void *base, long nmemb, long size,
int (*compar)(const void *, const void *));
#endif
class inst_t {
public:
long linenum;
};
typedef list<inst_t *> inst_list_t;
template <class list_t>
void
sort( list_t *&list, int (*cmp)(const list_t **, const list_t **) =
compare )
{
int len = list->length();
list_t *iter;
list_t *table[ len ];
qsort( table, len, sizeof( list_t * ),
( int (*)(const void *,const void *)) cmp );
}
static int
compare_by_linenum( const inst_list_t **a, const inst_list_t **b )
{
return( (*a)->e->linenum - (*b)->e->linenum );
}
void
write_netlist( )
{
inst_list_t *list = 0;
sort( list, compare_by_linenum );
}
More information about the Gcc-bugs
mailing list