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);
        ^

Reply via email to