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