Re: [PATCH v3 01/16] bitops: Change parity8() return type to bool
From: Yury Norov
Date: Thu Mar 13 2025 - 12:31:36 EST
On Fri, Mar 07, 2025 at 11:33:40AM -0800, H. Peter Anvin wrote:
> On March 7, 2025 11:30:08 AM PST, Yury Norov <yury.norov@xxxxxxxxx> wrote:
[...]
> >> Instead of "bool" think of it as "bit" and it makes more sense
> >
> >So, to help people thinking that way we can introduce a corresponding
> >type:
> > typedef unsigned _BitInt(1) u1;
> >
> >It already works for clang, and GCC is going to adopt it with std=c23.
> >We can make u1 an alias to bool for GCC for a while. If you guys like
> >it, I can send a patch.
> >
> >For clang it prints quite a nice overflow warning:
> >
> >tst.c:59:9: warning: implicit conversion from 'int' to 'u1' (aka 'unsigned _BitInt(1)') changes value from 2 to 0 [-Wconstant-conversion]
> > 59 | u1 r = 2;
> > | ~ ^
> >
> >Thanks,
> >Yury
>
> No, for a whole bunch of reasons.
Can you please elaborate?