------- Comment #8 from manu at gcc dot gnu dot org  2007-01-26 16:56 -------
(In reply to comment #7)
> (In reply to comment #6)
> > OK. I see now. This seems hard to fix, since it is exposing the current
> > implementation of a conversion to bool.
> > 
> 
> No, it's not the 'current implementation', its the way the C and C++ standards
> say this has to happen.  When arithmetic operators are applied to sub-int 
> sized
> operands they are first converted to int (or unsigned int if they can't be
> represented in int -- which is only the case when you have a machine where
> sizeof(unsigned short) == sizeof(unsigned int), or something similar).
> 

I think I expressed myself badly. I meant that the warning is appropriate but
the message is confusing because it is exposing that when doing 

bool x = ~b; 

we actually do 

bool x = (~b != 0);

So an appropriate message would say something like:

test.cpp:5: warning: '(bool) ~b' is always true


But that is hard to achieve with the current implementation.

Don't you agree?


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=8715

Reply via email to