GCC version 3.4.2 and 4 inconsistency on "error: creating array with size zero (`0')"

Roberto Bagnara bagnara@cs.unipr.it
Thu Mar 24 16:17:00 GMT 2005


Call the following snippet `bug.cc':

struct a {
   static const int size = 0;
};

template <typename T>
struct p {
   int a[T::size]; // Here it says "error: creating array with size zero (`0')"
};

p<a> n;


template <typename T>
struct q {
   int a[0];       // Here it says nothing!
};

q<a> m;

$ g++ -v
Reading specs from /usr/local/lib/gcc/i686-pc-linux-gnu/3.4.2/specs
Configured with: ../gcc-3.4.2/configure --prefix=/usr/local
Thread model: posix
gcc version 3.4.2
$ g++ -c bug.cc
bug.cc: In instantiation of `p<a>':
bug.cc:10:   instantiated from here
bug.cc:7: error: creating array with size zero (`0')
$ /opt/beta/bin/g++ -v
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: ../gcc-4.0/gcc/configure --prefix=/opt/beta
Thread model: posix
gcc version 4.0.0 20050226 (prerelease)
$ /opt/beta/bin/g++ -c bug.cc
bug.cc: In instantiation of 'p<a>':
bug.cc:10:   instantiated from here
bug.cc:7: error: creating array with size zero ('0')


Should I report this as a bug?
If so, which kind of bug is it?
All the best,

     Roberto

-- 
Prof. Roberto Bagnara
Computer Science Group
Department of Mathematics, University of Parma, Italy
http://www.cs.unipr.it/~bagnara/
mailto:bagnara@cs.unipr.it



More information about the Gcc mailing list