home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: sparky!uunet!wupost!uwm.edu!news.mr.med.ge.com!rdsunx.crd.ge.com!bart!volpe
- From: volpe@bart.NoSubdomain.NoDomain (Christopher R Volpe)
- Subject: Re: Question to test general C knowledge
- Message-ID: <1992Dec13.051442.1867@crd.ge.com>
- Sender: volpe@bart (Christopher R Volpe)
- Nntp-Posting-Host: bart.crd.ge.com
- Reply-To: volpe@ausable.crd.ge.com
- Organization: GE Corporate Research & Development
- References: <Bz0A46.Cvu@watserv1.uwaterloo.ca> <19980@ksr.com> <1992Dec11.180939.20726@crd.ge.com> <1992Dec12.230520.771@thunder.mcrcim.mcgill.edu>
- Date: Sun, 13 Dec 1992 05:14:42 GMT
- Lines: 30
-
- In article <1992Dec12.230520.771@thunder.mcrcim.mcgill.edu>, mouse@thunder.mcrcim.mcgill.edu (der Mouse) writes:
- |> In article <1992Dec11.180939.20726@crd.ge.com>, volpe@bart.NoSubdomain.NoDomain (Christopher R Volpe) writes:
- |> > ^^^^^^^^^^^^
- |> > Why?
- |>
- |> Based on a sequence like
- |>
- |> ! compute needed values
- |> addl3 _i,$1,r0 ! compute value of ++i
- |> ! sequence point; do accumulated side-effects
- |> movl r0,_i ! store value of ++i into i
- |> incl _i ! increment i
- |>
- |> Thus we see the wisdom of ANSI's rule :-)
-
- Umm. I question whether it would be legal for the compiler to emit
- such code. The reason is that the value of the "++i" expression is
- "the value of i after the assignment". The first assembly statement
- computes this value as "3". However, the "value of i after the assignment"
- is determined by the result of the "incl _i" statement, and that
- value is 4, which contradicts the definition of the value of the "++i"
- expression.
-
- -Chris
-
- --
- ==================
- Chris Volpe
- G.E. Corporate R&D
- volpecr@crd.ge.com
-