RE: [PATCH v2 01/12] regmap-irq: Convert bool bitfields to unsigned int

David Laight
2022-06-24T14:29:05Z

From: Joe Perches
> Sent: 24 June 2022 14:45
...
> I'm trying to show that conversions of bool:1->unsigned int:1
> as being trivial are not so trivial after all.
>
> It's fairly common to have code like:
>
> [bool] foo.bar = some_value & SETTING;
>
> where some value is tested for a mask/bit and a non-zero is true.
>
> So conversions of foo.bar from bool:1 to unsigned int:1 are not
> wise unless all possible side effects are known.

I can never decide whether:
bool_c = bool_a & bool_b;
can be compiled to a simple 'and' instruction, or requires a
load of instructions in case bool_a and/or bool_b has a non-zero
value without the bottom bit set.

All other C types are cpu register types - so you know what happens.
IMHO bool is an abomination and should not be used :-)

David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)