This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

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


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]