Debian Codegraph @

gcc/testsuite/g++.dg/cpp2a/constexpr-inst1.C

raw
1 // Testcase from P0859
2 // { dg-do compile { target c++14 } }
3
4 template<typename T> constexpr int f() { return T::value; } // { dg-error "int" }
5 template<bool B, typename T> void g(decltype(B ? f<T>() : 0));
6 template<bool B, typename T> void g(...);
7 template<bool B, typename T> void h(decltype(int{B ? f<T>() : 0}));
8 template<bool B, typename T> void h(...);
9 void x() {
10 g<false, int>(0); // OK, B ? f<T>() : 0 is not potentially constant evaluated
11 h<false, int>(0); // error, instantiates f<int> even though B evaluates to false and
12 // list-initialization of int from int cannot be narrowing
13 }