Sequence points 
Author Message
 Sequence points

I've already seen a lot of discussions "i = ++i;". Can you, please,
explain what is sequence points and how can I understand, where they
are, for e.g
i = fun(i++);
std::cout<<i<<++i<<std::endl;
e.t.c


Tue, 02 Aug 2005 21:24:21 GMT  
 Sequence points

Quote:

> I've already seen a lot of discussions "i = ++i;". Can you, please,
> explain what is sequence points and how can I understand, where they
> are, for e.g

http://www.eskimo.com/~scs/C-faq/s3.html

Quote:
> i = fun(i++);
> std::cout<<i<<++i<<std::endl;

Very strange C syntax. :-)

Jirka



Tue, 02 Aug 2005 21:28:23 GMT  
 Sequence points

Quote:

> I've already seen a lot of discussions "i = ++i;". Can you, please,
> explain what is sequence points and how can I understand, where they
> are, for e.g
> i = fun(i++);

    1.  Sequence point (at end of preceding statement,
        most likely).
    2.  Evaluate `i++', yielding the original value of `i'.
        Also evaluate `fun' (which might, for example, be a
        function pointer variable).  The two evaluations may
        occur in any order, and may even be overlapped.
    3.  Sequence point after evaluating the arguments and
        before calling the function.  Sometime after (1)
        and before (3), the side-effect of incrementing `i'
        occurs.
    4.  Additional sequence points may be encountered in
        the execution of the function.  In any case, there
        will be a sequence point just before the function
        returns, so any side-effects occurring within the
        function will be complete by the time of the return.
    5.  Evaluation of the `=' operator now stores the
        returned value in `i'.
    6.  Sequence point at the end of the entire statement.

Quote:
> std::cout<<i<<++i<<std::endl;

    This isn't C.  I have no idea what it does, except that
I've seen similar gibberish rot the brains of formerly sane
programmers.

Quote:
> e.t.c

    This isn't C, nor is it Latin.  I guess it's evidence of
the afore-mentioned brain-rot.

--



Wed, 03 Aug 2005 01:18:18 GMT  
 Sequence points


Quote:
> I've already seen a lot of discussions "i = ++i;". Can you, please,
> explain what is sequence points and how can I understand, where they
> are, for e.g
> i = fun(i++);
> std::cout<<i<<++i<<std::endl;

Oops, that's C++, not C.

Quote:
> e.t.c

http://www.eskimo.com/~scs/C-faq/q3.8.html

-Mike



Wed, 03 Aug 2005 05:01:45 GMT  
 Sequence points
Quote:


>> I've already seen a lot of discussions "i = ++i;". Can you, please,
>> explain what is sequence points and how can I understand, where they
>> are, for e.g
>> i = fun(i++);

>    1.  Sequence point (at end of preceding statement,
>        most likely).
>    2.  Evaluate `i++', yielding the original value of `i'.
>        Also evaluate `fun' (which might, for example, be a
>        function pointer variable).  The two evaluations may
>        occur in any order, and may even be overlapped.
>    3.  Sequence point after evaluating the arguments and
>        before calling the function.  Sometime after (1)
>        and before (3), the side-effect of incrementing `i'
>        occurs.
>    4.  Additional sequence points may be encountered in
>        the execution of the function.  In any case, there
>        will be a sequence point just before the function
>        returns, so any side-effects occurring within the
>        function will be complete by the time of the return.
>    5.  Evaluation of the `=' operator now stores the
>        returned value in `i'.
>    6.  Sequence point at the end of the entire statement.

ITYM
     5.  Evaluate the `=' operator, yielding the value to be
         stored into i.
     6.  Sequence point at the end of the entire statement.
         At this point the side-effect of the `=' operator
         (assigning a value to i) has occurred.

        - Kevin.



Thu, 04 Aug 2005 08:39:42 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Assignment and sequence points

2. Sequence Points & Side Effects

3. Sequence point question (function result semantics)

4. Sequence point or not?

5. Yet another sequence point question

6. sequence point in printf's argument list?

7. Sequence points in initializers

8. Sequence Points, Aliasing & Optimisation

9. sequence points

10. Sequence points and undefined behaviour

11. Sequence points in this code

12. Sequence points

 

 
Powered by phpBB® Forum Software