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. $:
(a = 0) >= 0; gets transformed into (a = 0); , 1; This is some undesired early folding.
Hopefully we'll sort it out in GCC 6.