This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Add -Womitted-conditional-op warning
On Friday 02 February 2007 18:57, Joseph S. Myers wrote:
> On Fri, 2 Feb 2007, Andi Kleen wrote:
>
> > I implemented a warning for this case. I guess it's relatively obscure, but will
> > not hurt. The warning is enabled by default, but can be disabled with
> > -Wno-omitted-conditional-op.
>
> This extension seems like one that could be used in macros in system
> headers and so maybe the warning should be disabled by __extension__ (for
That would disable the warning completely for those headers then
because it can only happen in a __extension__ because it relies on a GNU
extension in the first place.
> C, see disable_extension_diagnostics / restore_extension_diagnostics).
> Or do you think that the particular cases you warn for are never going to
> arise from macros (given those could be replaced by ... ? 1 : ...)?
If it arises from macros it was very likely a mistake the macro
writer did (IMNSHO)
> > +@item -Wno-omitted-conditional-op
> > +@opindex Wno-omitted-conditional-op
> > +Don't warn for dangerous uses of the
> > +?: with omitted middle operand GNU extension. When the condition
> > +in the ?: operator is a computed boolean the omitted value will
> > +be always 1. Often the user expects it to be a value computed
> > +inside the conditional expression instead. Gcc by default warns
> > +for this, but this option disables it.
>
> Two spaces after "." at end of sentence in Texinfo. "GCC" not "Gcc". Use
> @code or @samp around "?:". Include a cross-reference to the section of
> the manual documenting this extension.
Thanks, will fix that.
-Andi