This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/60664] bool / out of range int comparison warning failure


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.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]