Article View: comp.std.c
Article #4431Re: On sequence points and evaluation order
From: Nick Maclaren
Date: Thu, 07 Dec 1995 14:10
Date: Thu, 07 Dec 1995 14:10
40 lines
2764 bytes
2764 bytes
In article <4a6r9u$hq5@rdsunx.crd.ge.com>, volpe@bart.crd.ge.com (Christopher R. Volpe) writes: |> In article <TANMOY.95Dec5221739@qcd.lanl.gov>, tanmoy@qcd.lanl.gov (Tanmoy Bhattacharya) writes: |> |> |> |>My question, which Chris was responding to, was whether the the i that |> |>is the left operand of the top-level +, henceforth called the |> |>top-level i, can be evaluated interleaved with the evaluation of f() |> |>(Remember, f() contains a i=1). If it can, then there is a possible |> |>sequence of evaluation where i is both modified (in f) and accessed |> |>(top-level i) without intervening sequence points. |> |> If that is the case, I'm switching back to Pascal. (0.1 :-)) I want to look at |> a function definition and be able to say, "Ok, here's a semicolon, and there's |> the next semicolon, and the only thing that's going to happen between these |> two is what's *written* between these two" (as far as the abstract machine is |> concerned, since obviously I don't give a hoot about what gets interleaved |> where for optimization purposes, as long as the semantics are intact.) I recommend switching back to Pascal, if that is powerful enough for your purposes :-( Not merely does the standard allow strange things to happen between semicolons, but I can witness that a very high proportion of compilers actually produce such code. On the other hand, many of the really ghastly examples that I have seen are associated with signal-handling, which is something you can't do at all in standard Pascal (or Fortran, for that matter). In extreme cases (like the Cray YMP), not merely do I have to make an unreasonable proportion of my local variables static AND volatile, but I have to compile the most sensitive parts of my code without any optimisation at all. That particular example does not involve signal handling and shows that, even if the standard mandates a particular instruction ordering, it is unsafe to rely on it. Nick Maclaren, University of Cambridge Computer Laboratory, New Museums Site, Pembroke Street, Cambridge CB2 3QG, England. Email: nmm1@cam.ac.uk Tel.: +44 1223 334761 Fax: +44 1223 334679
Technical Details
Message-ID:
<4a6sjr$t1j@lyra.csx.cam.ac.uk>Path:
arc1-ca.pugleaf.net!lyra.csx.cam.ac.uk!nmm1References:
<49l428$od0@bolverk.cs.cornell.edu> <49ojjp$hsm@newshost.lanl.gov> <49qiu7$25h@natasha.rmii.com> <49v3ii$nve@rdsunx.crd.ge.com> <1995Dec6.000503.6676@sq.com> <TANMOY.95Dec5221739@qcd.lanl.gov> <4a6r9u$hq5@rdsunx.crd.ge.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!lyra.csx.cam.ac.uk!nmm1 From: nmm1@cus.cam.ac.uk (Nick Maclaren) Newsgroups: comp.std.c Subject: Re: On sequence points and evaluation order Date: 7 Dec 1995 14:10:03 GMT Organization: University of Cambridge, England Distribution: world Message-ID: <4a6sjr$t1j@lyra.csx.cam.ac.uk> References: <49l428$od0@bolverk.cs.cornell.edu> <49ojjp$hsm@newshost.lanl.gov> <49qiu7$25h@natasha.rmii.com> <49v3ii$nve@rdsunx.crd.ge.com> <1995Dec6.000503.6676@sq.com> <TANMOY.95Dec5221739@qcd.lanl.gov> <4a6r9u$hq5@rdsunx.crd.ge.com> NNTP-Posting-Host: ursa.cus.cam.ac.uk