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

            Bug ID: 64439
           Summary: Incorrect location of -Wunused-value or false negative
           Product: gcc
           Version: 5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: chengniansun at gmail dot com

For the expression "a && ((b = 0) != 0)", GCC warns that the expression value
"((b = 0) != 0)" is not used. Should it point to the whole expression rather
this sub-expression? Or this is a false negative of -Wunused-value?


$: cat s.c 
void f(int a, int b) { 
  a && ((b = 0) != 0); 
}
$: 
$: gcc-trunk -c -Wunused-value s.c 
s.c: In function ‘f’:
s.c:2:17: warning: value computed is not used [-Wunused-value]
   a && ((b = 0) != 0); 
                 ^
$: 
$: clang-trunk -c -Wunused-value s.c
s.c:2:5: warning: expression result unused [-Wunused-value]
  a && ((b = 0) != 0); 
  ~ ^  ~~~~~~~~~~~~~~
1 warning generated.
$: 
$:

Reply via email to