On Thu, 22 Apr 2021 14:28:24 -0600 Martin Sebor via Gcc-patches <[email protected]> wrote:
> > enum E { e = 5 };
> > struct A { E e: 3; };
> >
> > constexpr int number_of_bits ()
> > {
> > A a = { };
> > a.e = (E)-1;
> > return 32 - __builtin_clz(a.e);
> > }
> >
>
> I had the same thought about using clz. It works in this case but
> not in if one of the enumerators is negative, or if the underlying
> type is signed.
or for -fshort-enums in this case as is.
