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/64609] No -Wbool-compare warning on "(a = 0 && 0) <= 4"


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

Eric Gallager <egallager at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |diagnostic
                 CC|                            |egallager at gcc dot gnu.org
            Summary|No -Wbool-compare warning   |No -Wbool-compare warning
                   |on "(a = 0 && 0) <= 4" and  |on "(a = 0 && 0) <= 4"
                   |"0 > a < 0"                 |

--- Comment #3 from Eric Gallager <egallager at gcc dot gnu.org> ---
(In reply to Chengnian Sun from comment #2)
> Another test case. 
> 
> 
> $: cat s.c 
> int a;
> void f() { 
>   (0 > a < 0);
> }
> $: 
> $: gcc-trunk -Wbool-compare -Wtype-limits -c s.c
> $:

This one warns for me:
$ /usr/local/bin/gcc -c -Wparentheses -Wbool-compare -Wbool-operation
-Wtautological-compare -Wint-in-bool-context -Wtype-limits 64609.c
64609.c: In function ‘f’:
64609.c:4:9: warning: comparison of constant ‘0’ with boolean expression is
always false [-Wbool-compare]
  (0 > a < 0);
         ^
64609.c:4:5: warning: comparisons like ‘X<=Y<=Z’ do not have their mathematical
meaning [-Wparentheses]
  (0 > a < 0);
   ~~^~~
$

The first one still doesn't warn though. Retitling to just be about the first
one.

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