[Bug c/59871] No unused value warning for comma expression
jakub at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Sat Jan 18 09:31:00 GMT 2014
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59871
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org,
| |mpolacek at gcc dot gnu.org
Target Milestone|--- |4.9.0
--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Confirmed, for say:
extern int bar ();
void
foo (int *p)
{
p[0] = (bar (), 1, bar ());
p[1] = (1, bar ());
bar (), 1, bar ();
bar (), 1;
1, bar ();
}
both g++ and clang warn about all 5 cases, while gcc only about 2 of them.
g++ gives:
pr59871.c:6:27: warning: right operand of comma operator has no effect
[-Wunused-value]
pr59871.c:7:19: warning: left operand of comma operator has no effect
[-Wunused-value]
pr59871.c:8:19: warning: right operand of comma operator has no effect
[-Wunused-value]
pr59871.c:9:12: warning: right operand of comma operator has no effect
[-Wunused-value]
pr59871.c:10:11: warning: left operand of comma operator has no effect
[-Wunused-value]
and gcc only:
pr59871.c:7:12: warning: left-hand operand of comma expression has no effect
[-Wunused-value]
pr59871.c:10:4: warning: left-hand operand of comma expression has no effect
[-Wunused-value]
I'd say we want to follow what C++ FE does.
More information about the Gcc-bugs
mailing list