On Sat, Jan 27, 2024 at 6:07 PM Thomas Voss via Gcc-bugs
<[email protected]> wrote:
>
> Hi all,
>
> Earlier today I decided to clone the GCC repo and build the latest code
> just to play around with some new C23 features. One thing I attempted
> was the following:
>
> typedef _BitInt(128) underlying;
> enum my_enum : underlying {
> FOO = (underlying)1 << 100;
> BAR = (underlying)1 << 101;
> };
>
> I expected this to work — it builds on Clang too — but it failed to
> compile with the error ‘invalid underlying type’ (or something like that;
> I’m going off of memory).
The trunk of clang rejects it:
```
<source>:4:20: error: 'underlying' (aka '_BitInt(128)') is an invalid
underlying type
4 | enum my_enum : underlying {
| ^
```
While clang 17.0 accepts it. So it looks like clang fixed their bug.
Thanks,
Andrew
>
> I took a look into the C23 working draft and I see no reference to
> bit-precise integers being disallowed as an underlying type to an
> enumeration. As a result I assume this is a bug in GCC so I’m reporting
> it here just in case. If it’s not a bug, do let me know why that is the
> case.
>
> --
> — Thomas