This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/53064] -Wsequence-point behaves inconsistently


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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]