1 // { dg-do run }
2 // { dg-options "-std=gnu++0x" }
3
4 // PR c++/33510
5 #define SIZE_FROM_CTOR
6 extern "C" void abort ();
7
8 template<int M, int N> struct pair
9 {
10 int i, j;
pairpair11 pair () : i (M), j (N) {}
12 };
13
14 template<int... M> struct S
15 {
fooS16 template<int... N> static int *foo ()
17 {
18 #ifdef SIZE_FROM_CTOR
19 static int x[] = { (M + N)..., -1 };
20 #else
21 static int x[1 + sizeof... N] = { (M + N)..., -1 };
22 #endif
23 return x;
24 }
25 };
26
27 template<typename... M> struct R
28 {
fooR29 template<typename... N> static int *foo ()
30 {
31 #ifdef SIZE_FROM_CTOR
32 static int x[] = { (sizeof(M) + sizeof(N))..., -1 };
33 #else
34 static int x[1 + sizeof... N] = { (sizeof(M) + sizeof(N))..., -1 };
35 #endif
36 return x;
37 }
38 };
39
bar()40 int *bar ()
41 {
42 return S<0, 1, 2>::foo<0, 1, 2> ();
43 }
44
baz()45 int *baz ()
46 {
47 return R<char, short, int>::foo<float, double, long> ();
48 }
49
50
main()51 int main ()
52 {
53 int *p = bar ();
54 if (p[0] != 0 || p[1] != 2 || p[2] != 4 || p[3] != -1)
55 abort ();
56 }
57