I had this question when I was reading the c-faq. As for
i = i++;
I ever thought it works in following two ways.
1.
i = i /*no sequencing point followed immediately*/
i++
; /*sequencing point */
So, result: i = i + 1;
2.
i++ /*no sequencing point followed immediately,
but will the increasing effect be lost?*/
i = i /*i was assigned to itself*/
; /*sequencing point */
So, result: i = i;
And the result isn't certain.
Do I think it correctly?
Ok, I'll give this one last try.
No, you do not think it correctly. The behavior of 'i = i++;' is
undefined, because it attempts to modify the same object twice between
sequence points (C99 6.5p2). The phrase "undefined behavior" means
behavior, upon use of a nonportable or erroneous program construct
or of erroneous data, for which this International Standard
imposes no requirements
(that's C99 3.4.3); a note says
Possible undefined behavior ranges from ignoring the situation
completely with unpredictable results, to behaving during
translation or program execution in a documented manner
characteristic of the environment (with or without the issuance of
a diagnostic message), to terminating a translation or execution
(with the issuance of a diagnostic message).
The standard places *no requirements* on the behavior of 'i = i ++;'.
It may increment i, it may not increment i, it may cause your computer
to burst into flames, it may make demons fly out of your nose.
You say you had a question about this while reading the FAQ. Question
3.3 says the behavior of that particular expression is undefined. It
refers to question 3.9 explains what undefined behavior means.
I am at a loss to understand why you're having difficulty with this,
especially considering how long you've been participating in this
newsgroup.
People are being rude to you because they are frustrated at your
repeated asking of questions that have already been clearly answered.
Some people are assuming that you're doing this deliberately, to be
annoying. I'm not *yet* ready to make that assumption.