Bug 64648

Summary: Incorrect message description of -Wunused-value
Product: gcc Reporter: Chengnian Sun <chengniansun>
Component: cAssignee: Not yet assigned to anyone <unassigned>
Status: NEW ---    
Severity: normal CC: manu
Priority: P3 Keywords: diagnostic
Version: 5.0   
Target Milestone: ---   
See Also: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107797
Host: Target:
Build: Known to work:
Known to fail: Last reconfirmed: 2015-01-18 00:00:00
Bug Depends on:    
Bug Blocks: 89180    

Description Chengnian Sun 2015-01-17 18:59:08 UTC
GCC emits a -Wunused-value warning with a wrong description for the expression "(a = 0) >= 0". There is no comma expression, but the message is 

        right-hand operand of comma expression has no effect

If I change the operator from ">=" to "!=", then the message is correct. 




$: cat t.c
int a;
void f() {
  (a = 0) != 0;
  (a = 0) >= 0;
}
$: 
$: gcc-trunk -c -Wunused-value t.c
t.c: In function ‘f’:
t.c:3:11: warning: value computed is not used [-Wunused-value]
   (a = 0) != 0;
           ^
t.c:4:11: warning: right-hand operand of comma expression has no effect [-Wunused-value]
   (a = 0) >= 0;
           ^
$: 
$: clang-trunk -c -Wunused-value t.c
t.c:3:11: warning: inequality comparison result unused [-Wunused-comparison]
  (a = 0) != 0;
  ~~~~~~~~^~~~
t.c:4:11: warning: relational comparison result unused [-Wunused-comparison]
  (a = 0) >= 0;
  ~~~~~~~~^~~~
2 warnings generated.
$:
Comment 1 Manuel López-Ibáñez 2015-01-18 13:23:39 UTC
(a = 0) >= 0; gets transformed into (a = 0); , 1;

This is some undesired early folding.
Comment 2 Marek Polacek 2015-01-18 13:27:36 UTC
Hopefully we'll sort it out in GCC 6.