Bug report for GNU C++ 2.95.1 on constant expression eval. in templates

Sven Rosvall sven.prqa@indigo.ie
Tue Feb 1 09:33:00 GMT 2000


Hi, just stumbled on this piece of code in a proprietary 
library that caused g++ to yell. I haven't seen it in
any list of known bugs and wouldn't either as it is a
bit wierd. This is what I have narrowed it down to:

File array.cc:
--------
template <class T> struct foo {
  static const int bar [3];
};
template <class T> const int foo<T>::bar [2+1] = { 0, 0, 0 };
------
% g++ -c array.cc
array.cc:4: conflicting types for `const int foo<T>::bar[(2 + 1)]'
array.cc:2: previous declaration as `const int foo<T>::bar[3]'
% g++ --version
2.95.1

G++ accepts the code if either the template bit goes away 
or "2+1" is changed to "3".

I don't expect this bug report to have any higher priority
but it might be fun for you guys to study.

	/ Sven



More information about the Gcc-bugs mailing list