Re: Why is this expression detected as undefined by GCC, Splint?



On 12월30일, 오후10시18분, Eric Sosman <esos...@xxxxxxxxxxxxxxxxxxxx> wrote:
On 12/30/2010 1:50 AM, amuro wrote:

Hi, I wonder why the following expression is detected as undefined
expression. In my opinion, this is a "defined" expression.

x = *(x++, p); // line 21

Undefined behavior: `x' is modified twice without an intervening
sequence point.

Yes, there's a sequence point between `x++' and `p'. But there's
no sequence point between `x=' and `x++'.

[about x = *(x++, p);]

I think it can be derived that there exists sequence point between
`x=`(assignment) and side effect generated by 'x++' with respect to
all the possible(acceptable) evaluation sequences.

* "a > b" means that b is sequenced before a

'x=' > value computation of LHS and RHS of x= which requires
"evaluating p" // by 6.5.16p3
"evaluating p" > side effect by x+
+ // by comma op

Therefore.. 'x=' is sequenced before side effect of x++.
IOW, there's a sequence point between 'x=' and 'x++'..
.