This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/60664] bool / out of range int comparison warning failure
- From: "dcb314 at hotmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 13 Oct 2014 13:38:39 +0000
- Subject: [Bug c++/60664] bool / out of range int comparison warning failure
- Auto-submitted: auto-generated
- References: <bug-60664-4 at http dot gcc dot gnu dot org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60664
David Binderman <dcb314 at hotmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |REOPENED
Resolution|FIXED |---
--- Comment #7 from David Binderman <dcb314 at hotmail dot com> ---
(In reply to Manuel LÃpez-IbÃÃez from comment #6)
> I think it is a different warning for which clang uses the same switch
> (-Wbool-compare only warns about boolean expressions). It is also not
> obvious that there is a bug there. Perhaps it is a false positive by Clang.
I looked into this and the definition of SUBREG_CHECK_PROMOTED_SIGN
around line 2200 of gcc/rtl.h seems important.
#define SUBREG_CHECK_PROMOTED_SIGN(RTX, SIGN) \
((SIGN) == SRP_POINTER ? SUBREG_PROMOTED_GET (RTX) == SRP_POINTER \
: (SIGN) == SRP_SIGNED ? SUBREG_PROMOTED_SIGNED_P (RTX) \
: SUBREG_PROMOTED_UNSIGNED_P (RTX))
Leaving aside the side issue of ? : being right associative,
so some () would help clarify, I notice that
const int SRP_POINTER = -1;
const int SRP_SIGNED = 0;
const int SRP_UNSIGNED = 1;
const int SRP_SIGNED_AND_UNSIGNED = 2;
so it looks as if this bitfield
unsigned unsigned_flag : 1;
is being compared to SRP_POINTER. One possible fix might be to change
the value of SRP_POINTER to 3 and see if the problem goes away.
Clang certainly seems to be finding a problem, AFAIK.