[bool wrapping] Request for warnings on implicit bool to int conversions

mathog mathog@caltech.edu
Wed Mar 28 22:52:00 GMT 2012


On 28-Mar-2012 15:20, Michael Witten wrote:

> However, it seems to me that toggling the value with the idiom:
>
>  --b;
>
> is aesthetically preferable to the more elaborate:
>
>   b = !b;

Aesthetically, not logically.  Neither of these makes the least bit of 
sense:

    one less than False
    one less than True

A better solution for the aesthetics would have been (it is a bit late 
now) to implement the missing unary negation operator:

   !!b;  //T->F, F->T

That operator would save even more program characters for the other int 
types, where it would be equivalent to:

   (i==0 ? 1 : 0);


Regards,

David Mathog
mathog@caltech.edu
Manager, Sequence Analysis Facility, Biology Division, Caltech



More information about the Gcc mailing list