🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #2159

order of sequence points in subexpressions

#2159
From: David Nelson
Date: Tue, 29 Sep 1992 22:25
32 lines
2055 bytes
We all know that "x = y[++i] + z[++i];" is asking for trouble. But what
about: "a = b[i+=1,i] + c[i+=1,i];". The comma operators have introduced
sequence points.

From ANSI 2.1.2.3 Program Execution
 ... At certain specified points in the execution sequence called sequence
 points, all side effects of previous evaluations shall be complete and no
 side effects of subsequent evaluations shall have taken place.

From ANSI 3.3 Expressions
     Between the previous and next sequence point an object shall have its
 stored value modified at most once by the evaluation of an expression. 
 ...
     Except as indicated by the syntax or otherwise specified later (for the
 function-call operator (), &&, ||, ?:, and comma operators), the order of
 evaluation of subexpressions and the order in which side effects take place
 are both unspecified.

For my hypothetical implementation, I choose to implement evaluation of the
subexpressions to '+' in parallel. With the second example, there are a
couple extra sequence points to worry about. But is there any relationship
between the two sequence points, or does the sequence point at the comma
operator only affect the subexpressions to the comma.

My interpretation would be that the sequence point only affects the
subexpression of the operation that introduced the sequence point. Anyone
care to confirm or reject this interpretation.

David Nelson               UUCP:      ...!uunet!kailand!dnelson
Kuck and Associates        Internet:  dnelson@kai.com 
1906 Fox Drive		   #include <std/disclaimer>
Champaign, IL   61820      Optimizing software for super computers
Technical Details
Message-ID: <1992Sep29.222521.9221@kai.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!kailand!david

Show Full Headers
Complete Article Headers
Newsgroups: comp.std.c
Path: arc1-ca.pugleaf.net!sparky!uunet!kailand!david
From: david@kai.com (David Nelson)
Subject: order of sequence points in subexpressions
Message-ID: <1992Sep29.222521.9221@kai.com>
Summary: What is the relationship between sequence points in different subexpressions
Keywords: sequence points
Organization: Kuck and Associates, Champaign IL
Date: Tue, 29 Sep 1992 22:25:21 GMT
Lines: 32