Debian Codegraph @

gcc/testsuite/g++.dg/cpp/embed-25.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 unsigned char buf[] = {
34 #embed __FILE__
35 };
36 if (x.size () != sizeof (buf))
37 __builtin_abort ();
38 unsigned int i = 0;
39 for (auto a = x.begin (); a < x.end (); ++a, ++i)
40 if (a->b != buf[i])
41 __builtin_abort ();
42 c = true;
43 }
44 bool c;
45 };
46
47 C c {
48 #embed __FILE__
49 };
50
51 int
52 main ()
53 {
54 if (!c.c)
55 __builtin_abort ();
56 }