Debian Codegraph @

gcc/testsuite/g++.dg/cpp0x/pr118671.C

raw
1 // PR c++/118671
2 // { dg-do run { target c++11 } }
3 // { dg-options "-O2" }
4
5 namespace std {
6 template <typename T>
7 struct initializer_list {
8 private:
9 T *_M_array;
10 decltype (sizeof 0) _M_len;
11 public:
12 constexpr decltype (sizeof 0)
13 size () const noexcept { return _M_len; }
14 constexpr const T *
15 begin () const noexcept { return _M_array; }
16 constexpr const T *
17 end () const noexcept { return begin () + size (); }
18 };
19 }
20
21 struct A {} a;
22
23 struct B {
24 constexpr B (int x) : B (a, x) {}
25 template <typename... T>
26 constexpr B (A, T... x) : b(x...) {}
27 int b;
28 };
29
30 struct C {
31 C (std::initializer_list<B> x)
32 {
33 if (x.size () != 130)
34 __builtin_abort ();
35 unsigned int i = 1;
36 for (auto a = x.begin (); a < x.end (); ++a)
37 if (a->b != i)
38 __builtin_abort ();
39 else
40 i = (i & 15) + 1;
41 c = true;
42 }
43 bool c;
44 };
45
46 C c { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
47 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
48 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
49 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
50 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
51 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
52 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
53 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
54 1, 2 };
55
56 int
57 main ()
58 {
59 if (!c.c)
60 __builtin_abort ();
61 }