2 // { dg-do compile { target c++11 } }
5 extern int nonconst_func(int);
6 constexpr int identity(int x) { return x; }
7 constexpr int zero() { return identity(0); }
8 constexpr int one() { return identity(1); }
10 // Correctly accepted.
11 constexpr int three = one() ? 3 : nonconst_func(0);
13 // Incorrectly accepted. See [dcl.constexpr] #5:
14 // For a constexpr function, if no function argument values exist
15 // such that the function invocation sub-stitution would produce a
16 // constant expression (5.19), the program is ill-formed; no diagnostic
18 constexpr int bogus() { return zero () ? 3 : nonconst_func(0); } // { dg-error "nonconst_func" }
20 // Correctly rejected (not sure why).
21 constexpr int correct_error() { return nonconst_func(0); } // { dg-error "nonconst_func" }
23 // Correctly rejected.
24 constexpr int z = bogus(); // { dg-error "" }
26 // This is also correctly rejected.
27 constexpr int correct_failure() { return 0 ? 3 : nonconst_func(0); } // { dg-error "nonconst_func" }