Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!mephisto!ncar!ames!amdcad!nucleus!tim From: tim@nucleus.amd.com (Tim Olson) Newsgroups: comp.graphics Subject: Re: Integral Square Root Message-ID: <28569@amdcad.AMD.COM> Date: 31 Dec 89 22:31:57 GMT References: <9170@cbmvax.commodore.com> <21550@mimsy.umd.edu> <9175@cbmvax.commodore.com> Sender: news@amdcad.AMD.COM Reply-To: tim@amd.com (Tim Olson) Organization: Advanced Micro Devices, Inc., Austin, Texas Lines: 61 Summary: Expires: Sender: Followup-To: In article <9175@cbmvax.commodore.com> mitchell@cbmvax.commodore.com (Fred Mitchell - PA) writes: | NOT WRONG- Let's analyze this line more closely (exploded IF, here we come!)... | | if ( | ( rb = r + | (b=1< int sum; char *p; /*...*/ sum = sum * 10 - '0' + ((*(p++)) = (getchar()))); the expression statement is groupsed as if it were written as sum = (((sum * 10) - '0') + ((*(p++)) = (getchar()))); but the actual increment of p can occur at any time between the previous sequence point and the next sequence point (the ;), and the call to getchar can occur at any point prior to the need of its returned value. The key here is the concept of a "sequence point". Any side-effects (such as assignment) in an expression can occur at any time as long as they are complete at the sequence point. This leads to the restriction in section 3.3: 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 to be stored. The expression (rb = r + (b=1<