🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #4449

Re: On sequence points and evaluation order

#4449
From: Nick Maclaren
Date: Fri, 08 Dec 1995 20:39
39 lines
2466 bytes
In article <4a9mnh$3hn@rdsunx.crd.ge.com>,
Christopher R. Volpe <volpe@ausable.crd.ge.com> wrote:
>In article <4a6sjr$t1j@lyra.csx.cam.ac.uk>, nmm1@cus.cam.ac.uk (Nick Maclaren) writes:
>|> 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).
>|>
>Can you give me an example of the kind of code that compilers generate that
>indicates that something funny is going on between sequence points?

Not easily.  What they do is to move assignments across sequence points,
in cases where only signal handlers or debuggers can detect the move,
and assume that nobody will notice!  Sometimes they make incorrect
moves, and sometimes don't update locations before function calls.  It
all depends.

>|>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.
>
>If a particular buggy compiler refuses to accept identifiers with the prefix 
>"_xyxy", does that make it unsave to use such identifiers in general?

Yes and no.  It does, if at least one compiler handles them incorrectly
and you have reason to believe that others will do the same.  I gave
the Cray YMP as an example - it is NOT the only compiler that has
produced demonstrably wrong code from a correct program of mine.


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: <4aa7qg$5ln@lyra.csx.cam.ac.uk>
Path: arc1-ca.pugleaf.net!lyra.csx.cam.ac.uk!nmm1
References: <49l428$od0@bolverk.cs.cornell.edu> <4a6r9u$hq5@rdsunx.crd.ge.com> <4a6sjr$t1j@lyra.csx.cam.ac.uk> <4a9mnh$3hn@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: 8 Dec 1995 20:39:44 GMT
Organization: University of Cambridge, England
Message-ID: <4aa7qg$5ln@lyra.csx.cam.ac.uk>
References: <49l428$od0@bolverk.cs.cornell.edu> <4a6r9u$hq5@rdsunx.crd.ge.com> <4a6sjr$t1j@lyra.csx.cam.ac.uk> <4a9mnh$3hn@rdsunx.crd.ge.com>
NNTP-Posting-Host: apus.cus.cam.ac.uk