[Bug c++/77434] warn about suspicious precedence of ternary operator (?:)

bernd.edlinger at hotmail dot de gcc-bugzilla@gcc.gnu.org
Thu Sep 1 21:04:00 GMT 2016


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

--- Comment #7 from Bernd Edlinger <bernd.edlinger at hotmail dot de> ---
(In reply to joseph@codesourcery.com from comment #6)
> On Thu, 1 Sep 2016, bernd.edlinger at hotmail dot de wrote:
> 
> > +       warning_at (location, 0,
> > +                   "?: expression using integer constants in boolean
> > context");
> 
> This should of course be enabled by some -W option (new or existing, and 
> enabled by -Wall in any case); warnings without an option to control them 
> should be avoided.

sure. It is only an experiment so far.  But it feels quite right.

The location info is not optimal: at the closing parenthesis.
I am not sure how to name the warning, and if there is a better
way to tell the user what's wrong with the code.


More information about the Gcc-bugs mailing list