Merged revisions 208012,208018-208019,208021,208023-208030,208033,208037,208040-20804...
[official-gcc.git] / main / gcc / testsuite / g++.dg / cpp0x / constexpr-ref4.C
blobce1ce5235c08f8f44874aac5e3f4cc50df1fd2ac
1 // PR c++/54777
2 // { dg-do compile { target c++11 } }
4 struct S
6   int s[1];
7   constexpr const int &foo (unsigned i) { return (i < 1 ? 0 : throw 1), s[i]; }
8   constexpr const int &bar (unsigned i) { return i < 1 ? s[i] : (throw 0, s[i]); }
9 };
11 int
12 main ()
14   constexpr S a {};
15   constexpr int i = a.foo (0);
16   constexpr int j = a.bar (0);
17   static_assert (i == j, "Ouch");