https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119058
Bug ID: 119058 Summary: wbN: A suffix for specifying the width of a bit-precise integer literal Product: gcc Version: 15.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: alx at kernel dot org Target Milestone: --- Currently, we have no way to specify the width of a bit-precise integer literal. We only have the wb suffix, which say "pick the smaller width possible". That wb suffix is insufficient, as sometimes we need a type wider than the value we're using, if we're going to use for example shifts. As an example, there's no good way (and by good, I mean something that doesn't involve casts) to create a value of width N (let's use 3 as a small example) where all bits are 1 except for the leftmost (or rightmost) one. alx@debian:~/tmp$ cat bw.c int main(void) { unsigned _BitInt(3) i = ~0wb >> 1; return i; } alx@debian:~/tmp$ gcc -Wall -Wextra bw.c alx@debian:~/tmp$ ./a.out; echo $? 7 alx@debian:~/tmp$ clang -Weverything -Wno-c23-extensions -Wno-bit-int-extension bw.c bw.c:4:31: warning: implicit conversion changes signedness: '_BitInt(2)' to 'unsigned _BitInt(3)' [-Wsign-conversion] 4 | unsigned _BitInt(3) i = ~0wb >> 1; | ~ ~~~~~^~~~ 1 warning generated. alx@debian:~/tmp$ ./a.out; echo $? 7 It would make sense to be able to write it like this (IMO): unsigned _BitInt(3) i = ~0wb3u >> 1; // stores the value 5 (0b011).