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/77292] Spurious warning: logical not is only applied to the left hand side of comparison


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

Segher Boessenkool <segher at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |segher at gcc dot gnu.org

--- Comment #11 from Segher Boessenkool <segher at gcc dot gnu.org> ---
(In reply to Manuel López-Ibáñez from comment #4)
> Note that Clang suggests two ways to silence the warning:
> 
> prog.cc:9:10: note: add parentheses after the '!' to evaluate the comparison
> first
>   return !a == b;
>          ^
>           (     )
> prog.cc:9:10: note: add parentheses around left hand side expression to
> silence this warning
>   return !a == b;
>          ^
>          ( )

Both of these suggestions are not so good.  "!(a == b)" is better written
as "a != b", and "!(a) == b" is just horrible.

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