Bug 64648 - Incorrect message description of -Wunused-value
Summary: Incorrect message description of -Wunused-value
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 5.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: diagnostic
Depends on:
Blocks: Wunused
  Show dependency treegraph
 
Reported: 2015-01-17 18:59 UTC by Chengnian Sun
Modified: 2022-11-21 17:46 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2015-01-18 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.