Debian Codegraph @

gcc/testsuite/g++.dg/ext/char8_t-limits-1.C

raw
1 // Test for unsignedness and that the max limit of char8_t is at least 0xFF
2 // when -fchar8_t is enabled.
3 // { dg-do compile }
4 // { dg-options "-std=c++17 -fchar8_t" }
5
6 static_assert(u8'\xFF' == 0xFF, "Error");
7 static_assert(u8"\xFF"[0] == 0xFF, "Error");
8 static_assert(char8_t(-1) >= 0, "Error");
9 static_assert(char8_t{-1} >= 0, "Error"); // { dg-error "narrowing conversion of .-1. from .int. to .char8_t." "char8_t" }