Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!mips!decwrl!sgi!davea@quasar.wpd.sgi.com From: davea@quasar.wpd.sgi.com (David B.Anderson) Newsgroups: comp.sys.sgi Subject: Re: C compiler weirdness? Message-ID: <97139@sgi.sgi.com> Date: 12 Apr 91 20:49:11 GMT References: <1991Apr8.023545.11197@jarvis.csri.toronto.edu> <4597.on.Mon,.8.Apr.91.18:32:50.EDT.@sct60a.sunyct.edu> <1991Apr12.175909.5194@helios.physics.utoronto.ca> Sender: guest@sgi.sgi.com Reply-To: davea@quasar.UUCP (David B.Anderson) Organization: Silicon Graphics, Inc., Mountain View, CA Lines: 38 In article <1991Apr12.175909.5194@helios.physics.utoronto.ca> mark@cita.toronto.edu writes: >David Blythe wrote ... > >| I recently dug up a copy of the hoc calculator described in kernighan & pike >| only to discover that the C compiler does not increment pc until after the >| function call returns in the following statment: >| (*(*pc++))(); >| whereas the rest of the program is assuming it is done before the function is >| actually called. Is the compiler interpretation supposed to be implementation >| dependent? I would suspect not, but then I can't believe no one else has [ ] >Sorry, but this example is irrelevant to the bug being reported (and it is a >bug, if the behaviour of the SGI compiler is in fact what David reports it to Since Mark Bartelt claims that the compiler is wrong, I'll step up to its defense (I do not claim that the compiler version used is ANSI C): ANSI C: 3.3.2.2, page 42. line 20. ``The order of evaluation of the function designator, the arguments, and subexpressions within the arguments is unspecified, but there is a sequence point before the actual call.'' The Standard does not say whether the sequence point is before or after the evaluation of the function designator. The following is thus _a_ legal sequence: evaluate arguments (none in the case above) sequence point (arguments evalation complete) evaluate function designator call function increment pc statement sequence point So IMO our code generation is legal in this case. (case dismissed :-) Regards, [ David B. Anderson Silicon Graphics (415)335-1548 davea@sgi.com ] [``What can go wrong?'' --Calvin to Hobbes]