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++'..
.



Relevant Pages

  • Re: Well Ordering the Reals
    ... >> uses this sequence to construct a new real c that is guaranteed ... >> to not be equal to any of the reals on the list. ... >endpoints of the intervening and shrinking interval can never be reached ... Daryl McCullough ...
    (sci.math)
  • Re: to guru : strange C++ operator behaviour
    ... >> change the value of a variable more than once with an intervening ... The compiler is allowed to do whatever it wants, ... >> including formatting your harddisk. ... Search for sequence point ...
    (comp.lang.cpp)
  • Re: Why is this expression detected as undefined by GCC, Splint?
    ... `x' is modified twice without an intervening ... the sequence point of the comma operator must precede the ...
    (comp.lang.c)
  • Re: Find The Bug
    ... >> The code modifies the value of i twice without an intervening ... sequence points ...
    (comp.lang.cpp)
  • Re: why is it so ?
    ... > to visualise how the sequence point makes the second statement ... modified more than once between sequence points, your example modifies ... i twice without an intervening SP, ...
    (comp.lang.c)