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


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53064

--- Comment #3 from Wenbin Lv <wenbin816 at gmail dot com> 2012-04-25 14:56:48 UTC ---
(In reply to comment #1)
> >  a + (++a ? 0 : 0);
> 
> Hmm, I don't think there is a sequence point issue here compared to the other
> case where it might cause an undefined code.
> 
> (++a ? 0 : 0) is all in done in one sequence point so that is defined and then
> added to a.  a might be accessed before or after the sequence point where a is
> modified but there is a sequence point between the access and the modification.

Sorry I don't quite understand your reply. Did you mean there are sequence
points before and after evaluation of (++a ? 0 : 0) (my best guess)? If so,
please note that extra parentheses do not import extra sequence points; the C
standard only guarantees that there is a sequence point between the evaluations
of the first and the second (or third) operands of the conditional operator.

And what confuses me is that the first expression seems to have all the
sequence points that the second have, plus another one between the evaluation
of argument and the function call, but is said to be undefined.


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