C++ regression from g++-2.95.2

Theodore Papadopoulo Theodore.Papadopoulo@sophia.inria.fr
Mon Dec 6 05:57:00 GMT 1999


I feel like I'm getting nuts...
Three weeks ago, I reported a bug with the gnu variable length arrays...
Marked pointed to me a patch that had just been applied:

> 1999-11-15  Jason Merrill  <jason@casey.cygnus.com>
> 
>       * cp-tree.h, decl.c (compute_array_index_type): Make nonstatic.
>       * pt.c (tsubst, case INTEGER_TYPE): Call it.  
>       Check uses_template_parms.

I tried it and thought it had corrected my problem. But now it seems 
that I gooffed somewhere as I still see the problem... I guess I used 
the wrong compiler (ie gcc-2.95.2) and thought that the problem was 
cured. But it is not....

So here is it again... it has to do with variable lenght arrays used in 
templated functions:

mururoa->/u/corse/2/robotvis/gnu/egcs/bin/g++ -v
Reading specs from /u/corse/2/robotvis/gnu/egcs/bin/../lib/gcc-lib/i686-pc-linux-gnu/2.96/specs
gcc version 2.96 19991115 (experimental)
mururoa->/u/corse/2/robotvis/gnu/egcs/bin/g++ -c TempGnuDynArray.C 
TempGnuDynArray.C: In function `void g (unsigned int) [with T = double]':
TempGnuDynArray.C:17:   instantiated from here
TempGnuDynArray.C:12: invalid type argument of `unary *'

mururoa->g++ -v
Reading specs from /usr/local/gcc/lib/gcc-lib/i686-pc-linux-gnu/2.95.2/specs
gcc version 2.95.2 19991024 (release)
mururoa->g++ -c TempGnuDynArray.C
mururoa->g++ -v
Reading specs from /net/home/robotvis/gnu/egcs/lib/gcc-lib/i686-pc-linux-gnu/2.96/specs
gcc version 2.96 19991205 (experimental)
mururoa->g++ -c TempGnuDynArray.C 
TempGnuDynArray.C: In function `void g (unsigned int) [with T = double]':
TempGnuDynArray.C:20:   instantiated from here
TempGnuDynArray.C:12: invalid type argument of `unary *'
TempGnuDynArray.C:12: confused by earlier errors, bailing out

mururoa->cat TempGnuDynArray.C 
// Build don't link:
// Origin: Theo Papadopoulo <Theodore.Papadopoulo@sophia.inria.fr>

inline const unsigned& f(const unsigned& a) {
	return a;
}

template <class T>
void
g(const unsigned n)
{
	double D[f(n)];
}

int main()
{
	g<double>(18);
}


Note I checked that the same wrong behaviour appears with the 19991116 version
of the compiler.

 --------------------------------------------------------------------
 Theodore Papadopoulo
 Email: Theodore.Papadopoulo@sophia.inria.fr Tel: (33) 04 92 38 76 01
 --------------------------------------------------------------------





More information about the Gcc-bugs mailing list