This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/33510] New: Array size of array with size determined by the initializer wrong with packs
- From: "jakub at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 20 Sep 2007 19:22:02 -0000
- Subject: [Bug c++/33510] New: Array size of array with size determined by the initializer wrong with packs
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
See http://gcc.gnu.org/ml/gcc-patches/2007-09/msg01600.html
// { dg-do run }
// { dg-options "-std=gnu++0x" }
extern "C" void abort ();
template<int M, int N> struct pair
{
int i, j;
pair () : i (M), j (N) {}
};
template<int... M> struct S
{
template<int... N> static int *foo ()
{
#ifdef SIZE_FROM_CTOR
static int x[] = { (M + N)..., -1 };
#else
static int x[1 + sizeof... N] = { (M + N)..., -1 };
#endif
return x;
}
};
int *bar ()
{
return S<0, 1, 2>::foo<0, 1, 2> ();
}
int main ()
{
int *p = bar ();
if (p[0] != 0 || p[1] != 2 || p[2] != 4 || p[3] != -1)
abort ();
}
should IMHO behave the same whether -DSIZE_FROM_CTOR is used or not.
--
Summary: Array size of array with size determined by the
initializer wrong with packs
Product: gcc
Version: 4.3.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: jakub at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33510