Is there a sequence point between the two assignments in the following code:
f(f(x=1,1),x=2);
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The relevant quote from the (draft) standard [6.5.2.2, 10] is:
So for your expression, the first argument (in particular the call to
f) could beevaluated before the second argument; e.g.:
Or, it could be evaluated after the second argument; e.g.:
[The function call itself can (and most probably will) contain more sequence points (in particular if it contains a
returnstatement).]Depending on that, there is a sequence point between the assignments or not.
It is up to the platform (“unspecified”).
Since in the 2nd case, you are assigning to
xtwice between two sequence points, you have undefined behaviour on such a platform.