This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/8715] '~' operator for unsigned char and conversion to bool
- From: "rearnsha at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 26 Jan 2007 17:03:29 -0000
- Subject: [Bug c++/8715] '~' operator for unsigned char and conversion to bool
- References: <bug-8715-1654@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #9 from rearnsha at gcc dot gnu dot org 2007-01-26 17:03 -------
(In reply to comment #8)
> 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);
>
Or, more precisely,
bool x = (~(int) b) != 0;
> So an appropriate message would say something like:
>
> test.cpp:5: warning: '(bool) ~b' is always true
> Don't you agree?
>
Yes, that would be nice, but hard to implement.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=8715