Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!sdd.hp.com!elroy.jpl.nasa.gov!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? Summary: I was wrong. C compiler has a bug in 3.3. Message-ID: <97603@sgi.sgi.com> Date: 16 Apr 91 15:41:17 GMT References: <1991Apr8.023545.11197@jarvis.csri.toronto.edu> <97139@sgi.sgi.com> Sender: guest@sgi.sgi.com Organization: Silicon Graphics, Inc., Mountain View, CA Lines: 31 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++))(); Recently, I quoted 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.'' as justifying the Release 3.3.x C compiler in compiling the above statement. I was wrong and the 3.3 C compiler is wrong. The variable ``pc'' must be incremented after the function address is calculated but *before* the function is called. There is no ambiguity in the Standard, but I somehow misunderstood the quoted sentence in the Standard. I would like to thank Mark Bartelt (mark@cita.toronto.edu) for being persistent (via e-mail) and helping me to understand my error. The C compiler bug is fixed in the next release of IRIX (4.0). My apologies to anyone mislead by my error. Regards, [ David B. Anderson Silicon Graphics (415)335-1548 davea@sgi.com ] [``What can go wrong?'' --Calvin to Hobbes]