This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/20032] ICE on non-constant array size in template
- From: "reichelt at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 18 Feb 2005 13:00:24 -0000
- Subject: [Bug c++/20032] ICE on non-constant array size in template
- References: <20050217174446.20032.pentek_imre@mailbox.hu>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From reichelt at gcc dot gnu dot org 2005-02-18 13:00 -------
The problem can be reduced to the following testacse:
==================================
int Sum(int);
template<int> struct A
{
int X[Sum(2)];
void foo() { sizeof(X); }
};
void bar()
{
A<0> a;
a.foo();
}
==================================
The code is invalid, since the array size "Sum(2)" is not a constant.
Even the definition
inline int Sum(unsigned int n) { return n*(n+1)/2; }
from the original test case doesn't change this.
The ICE was fixed by Mark's patch for PR 18429
http://gcc.gnu.org/ml/gcc-cvs/2004-11/msg00582.html
We now (i.e. in gcc 4.0.0) emit a proper error message.
Closing, since this is not a regression.
--
What |Removed |Added
----------------------------------------------------------------------------
CC| |reichelt at gcc dot gnu dot
| |org
Status|UNCONFIRMED |RESOLVED
Keywords| |ice-on-invalid-code
Resolution| |FIXED
Summary|internal error |ICE on non-constant array
| |size in template
Target Milestone|--- |4.0.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20032