testsuite: 32 bit AIX 2 byte wchar
[official-gcc.git] / gcc / testsuite / g++.dg / cpp23 / narrowing-bool1.C
blob54906c9f99aa3a6aaeebc9878f7ed2b6dfbe6e81
1 // P1401R5: Narrowing contextual conversions to bool
2 // { dg-do compile { target c++11 } }
4 void f() noexcept(sizeof(char[2])); // { dg-error "narrowing" } conversion of value 2 to type bool
5 void g() noexcept(sizeof(char)); // OK, conversion of value 1 to type bool is non-narrowing
7 #if __cpp_conditional_explicit
8 struct S {
9   explicit(sizeof(char[2])) S(char); // { dg-error "narrowing" "" { target c++20 } }
10   explicit(sizeof(char)) S(bool); // OK, conversion of value 1 to type bool is non-narrowing
12 #endif
14 static_assert(sizeof(int[2]), ""); // OK, narrowing allowed
16 #if __cpp_if_constexpr
17 int main()
19   if constexpr (sizeof(int[2])) // OK, narrowing allowed
20     {}
22 #endif