From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=0.7 required=5.0 tests=BAYES_00,INVALID_DATE, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,1ff5003422436e4 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 1994-10-12 08:32:14 PST Path: bga.com!news.sprintlink.net!sundog.tiac.net!wizard.pn.com!Germany.EU.net!EU.net!howland.reston.ans.net!swiss.ans.net!newsgate.watson.ibm.com!watnews.watson.ibm.com!ncohen From: ncohen@watson.ibm.com (Norman H. Cohen) Newsgroups: comp.lang.ada Subject: Re: Easily-Read C++? Date: 12 Oct 1994 13:49:51 GMT Organization: IBM T.J. Watson Research Center Distribution: world Message-ID: <37gphv$nbt@watnews1.watson.ibm.com> References: <1994Oct7.153254.29848@swlvx2.msd.ray.com> <374uke$8mo@delphi.cs.ucla.edu> <37bno4$ko4@gnat.cs.nyu.edu> <1994Oct11.090047.9190@sei.cmu.edu> <37emsq$smg@gnat.cs.nyu.edu> Reply-To: ncohen@watson.ibm.com NNTP-Posting-Host: rios8.watson.ibm.com Date: 1994-10-12T13:49:51+00:00 List-Id: In article <37emsq$smg@gnat.cs.nyu.edu>, dewar@cs.nyu.edu (Robert Dewar) writes: |> is it permissible for ++c to STORE a different value from what it returns? ... |> Reading the C standard clearly does not answer my question, so we must |> presume that the two sequences of code have quite a different effect. Actually, the C standard clearly indicates that this can happen even in circumstances that do not involve concurrency. The second paragraph of ANSI C section 3.3 (which I think of as the ANSI C answer to Ada RM section 11.6, at least in its ability to keep language lawyers busy trying to interpret it) states: Between the previous and next sequence point an object shall have its stored value modified at most once by the evaluation of an expression. Furthermore, the prior value shall be accessed only to determine the value stored.[34] ------- [Footnote 34] This paragraph renders undefined statement expressions such as i = ++i + 1; while allowing i = i + 1; Sequence points are defined syntactically. They include, for example, the points after the evaluation of the left operand of the &&, ||, and comma operators and the ends of statements. The definition appears to me to presume a single-threaded model of execution. I suspect that a large portion of the C code in the field has technically undefined semantics because it violates the quoted paragraph. -- Norman H. Cohen ncohen@watson.ibm.com