g++: template <_A, _B = vector<_A>> & bogus definition -> ICE...
Jason Riedy
ejr@cise.ufl.edu
Fri Jul 10 11:47:00 GMT 1998
The following code generates an ICE. Looks like it's been there a
little while, but nothing beat me over the head after a quick skim
over the archives.
-- begin borken code
##include <vector>
template < class _A, class _B = vector<_A> >
class bgraph
{
public:
reserve_edge_lists_(int n_rows_per_col);
};
template < class _A, class _B >
bgraph<_BustsHere_>::reserve_edge_lists_(int n_rows_per_col) // <==
{
return;
}
int
main (void)
{
bgraph<size_t> bg;
bg.reserve_edge_lists_(1);
}
-- end borken code
The code is wrong; a correct version compiles. If you remove the
default and instantiate correctly, it gives a proper error on the
_BustsHere_ parameter. Also, if you change the default not to depend
on _A, you get a proper error.
g++ -v and uname -a output:
> gcc version egcs-2.91.47 19980709 (gcc2 ss-980609 experimental)
> Linux wendsleydale 2.1.108 #2 SMP Thu Jul 2 22:50:59 EST 1998 i686 unknown
> gcc version egcs-2.91.40 19980611 (gcc2 ss-980502 experimental)
> SunOS cave 5.6 Generic_105181-06 sun4u sparc SUNW,Ultra-2
I'm using the newer SGI STL, but I don't think that has any bearing...
Jason, who used to think that nothing could be worse to parse than
Fortran and has since been proven wrong by C++...
More information about the Gcc-bugs
mailing list