1 // PR c++/48089
2 // { dg-do compile { target c++11 } }
3 
4 // bang is ill-formed (diagnostic required) because its initializer is
5 // non-constant, because it uses the value of an uninitialized object.
6 
7 // s() is ill-formed (no diagnostic required) because there is no set of
8 // arguments that would produce a constant expression.
9 
10 // R() is well-formed because i is initialized before j.
11 
12 struct s {
ss13   constexpr s() : v(v) { }
14   int v;
15 };
16 
17 constexpr s bang;		// { dg-error "|" }
18 
19 struct R {
20   int i,j;
RR21   constexpr R() : i(42),j(i) { } // { dg-bogus "" }
22 };
23 
24 constexpr R r;			// { dg-bogus "" }
25 
26 // Ill-formed (no diagnostic required)
27 struct T {
28   int i;
fT29   constexpr int f() { return i; }
TT30   constexpr T(): i(0) { }
TT31   constexpr T(const T& t) : i(f()) { } // { dg-message "" }
32 };
33 
34 constexpr T t1;
35 // Ill-formed (diagnostic required)
36 constexpr T t2(t1);		// { dg-message "" }
37 
38 // Well-formed
39 struct U {
40   int i, j;
fU41   constexpr int f(int _i) { return _i; }
gU42   constexpr int g() { return i; }
UU43   constexpr U(): i(0), j(0) { }
UU44   constexpr U(const U& t) : i(f(t.i)),j(0) { } // { dg-bogus "" }
UU45   constexpr U(int _i) : i(_i),j(g()) { } // { dg-bogus "" }
46 };
47 
48 constexpr U u1;
49 constexpr U u2(u1);		// { dg-bogus "" }
50 constexpr U u3(1);		// { dg-bogus "" }
51