This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/53064] -Wsequence-point behaves inconsistently
- From: "manu at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 16 Mar 2015 16:28:21 +0000
- Subject: [Bug c/53064] -Wsequence-point behaves inconsistently
- Auto-submitted: auto-generated
- References: <bug-53064-4 at http dot gcc dot gnu dot org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53064
Manuel LÃpez-IbÃÃez <manu at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |diagnostic
Status|UNCONFIRMED |NEW
Last reconfirmed| |2015-03-16
CC| |manu at gcc dot gnu.org
Ever confirmed|0 |1
Severity|trivial |normal
--- Comment #4 from Manuel LÃpez-IbÃÃez <manu at gcc dot gnu.org> ---
This is a bug caused by early folding of (x ? 0 : 0). Similar to PR65430. The
actual code produced by GCC is:
int a = 0;
++a;, NON_LVALUE_EXPR <a>;;
and you actually get a warning for the unused value, which is even more
confusing:
test.c:5:5: warning: right-hand operand of comma expression has no effect
[-Wunused-value]
a + (++a ? 0 : 0);
^
If one prevents the folding, the warning is given:
test.c:5:8: warning: operation on âaâ may be undefined [-Wsequence-point]
a + (++a ? 0 : 1);
^