Debian Codegraph @

gcc/testsuite/g++.dg/cpp1z/static_assert1.C

raw
1 // PR c++/91388
2 // Make sure we don't emit -Wreturn-type in functions with failed static_asserts.
3 // { dg-do compile { target c++17 } }
4
5 template <int N>
6 int
7 foo ()
8 {
9 if constexpr (N <= 42)
10 return N;
11 else
12 static_assert (false, "too high N"); // { dg-error "too high N" }
13 } // { dg-bogus "no return statement in function returning non-void" }
14
15 int a = foo <0> ();
16 int b = foo <42> ();
17 int c = foo <100> ();