Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I was confused in the beginning regarding Johannes'(litb) statement but he mentioned that in :</p> <pre><code>i = (i, ++i, i) +1 </code></pre> <blockquote> <p>&lt; Johannes><br> If &lt; a > is assignment, and is an increment. <code>:s:</code> is a sequence point,then the side effects can be sequenced as follows between sequence points: <code>(i :s: i++&lt; a &gt;&lt;n&gt; :s: i) + 1</code>. The value of the scalar <code>i</code> was changed twice between the first and second sequence point here. The order in which the assignment and the increment happens is unspecified, and since between them there is no sequence point, it is not even atomic with respect to each other.This is one allowed ordering permitted by the unspecified ordering of these side effects.</p> <p>This is different to <code>(i++, i++)</code>, because the evaluation order of the two subexpressions is from left to right, and at the sequence point between them, the increment of the previous evaluation shall be complete, and the next increment shall not have yet taken place. This enforces that there is no change of the value of <code>i</code> between two sequence points, which makes <code>(i++, i++)</code> valid<br> &lt; /Johannes></p> </blockquote> <p>This made me think the sequence mentioned by litb is invalid because as per C99:</p> <blockquote> <p>6.5.16.1 (2) In simple assignment (=), the value of the right operand is converted to the type of the assignment expression and replaces the value stored in the object designated by the left operand.</p> </blockquote> <p>i.e. the value of the right operand needs to be known before the assignment side effect (modification of the value stored in the object corresponding to the left operand) </p> <blockquote> <p>6.5.17 (2) The left operand of a comma operator is evaluated as a void expression; there is a sequence point after its evaluation. Then the right operand is evaluated; the result has its type and value.</p> </blockquote> <p>i.e. the rightmost operand of the comma operation needs to be evaluated to know the value and type of the comma expression (and the value of the right operand for my example).</p> <p>So in this case, the 'previous sequence point' for the assignment side effect would, in effect, be the right-most comma operation. The possible sequence mentioned by Johannes is invalid.</p> <p>Please correct me if I am wrong.</p> <hr>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload