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++/77434] warn about suspicious precedence of ternary operator (?:)


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77434

Bernd Edlinger <bernd.edlinger at hotmail dot de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bernd.edlinger at hotmail dot de

--- Comment #4 from Bernd Edlinger <bernd.edlinger at hotmail dot de> ---
(In reply to joseph@codesourcery.com from comment #1)
> I think the key thing that makes this suspicious is the boolean context 
> combined with both halves of the conditional expression being constant.  
> A conditional expression with both halves constant in a boolean context 
> either always evaluates to the same value, as here, or could be replaced 
> simply by "(COND)" or "(!(COND))".
> 
> Alternatively, a conditional expression in a boolean context where either 
> half is a constant that's not 0 or 1 is suspicious.

I agree: <= for boolean seems questionable.

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