Newsgroups: comp.sys.sgi Path: utzoo!utgpu!news-server.csri.toronto.edu!helios.physics.utoronto.ca!aurora.physics.utoronto.ca!sysmark From: sysmark@aurora.physics.utoronto.ca (Mark Bartelt) Subject: Re: C compiler weirdness? (a final(?) postscript) Message-ID: <1991Apr16.185459.12633@helios.physics.utoronto.ca> Sender: news@helios.physics.utoronto.ca (News Administrator) Nntp-Posting-Host: aurora.physics.utoronto.ca Reply-To: mark@cita.toronto.edu Organization: University of Toronto Physics/Astronomy/CITA References: <1991Apr8.023545.11197@jarvis.csri.toronto.edu> <97139@sgi.sgi.com> <97603@sgi.sgi.com> Date: Tue, 16 Apr 1991 18:54:59 GMT In article <97603@sgi.sgi.com> davea@quasar.wpd.sgi.com (David B.Anderson) writes: [ regarding David Blythe's question about the compiler's misbehaviour when dealing with (*(*pc++))() ] | I would like to thank Mark Bartelt (mark@cita.toronto.edu) for being | persistent (via e-mail) and helping me to understand my error. Thanks for the thanks, but most of the credit really should go to Henry Spencer (UofT's local source of ultimate oracular wisdom on anything and everything related to C, UNIX, and a host of other things), who offered his interpretation of what the standard says. For those of you who may be interested, here are his comments: | ANSI C's sequence-point stuff is, in general, enough to make your head | ache. However, in this case the standard is clear [ ... ] | | 3.3.2.2: "The order of evaluation of the function designator, | the arguments, and the subexpressions within the arguments is unspecified, | but there is a sequence point before the actual call." | | This very issue -- increments vs. function calls -- was a hotly-debated | point both before and during standardization, hence the very explicit | resolution of it. Consulting Henry also afforded an opportunity to get my own (incorrect) opinions on a couple of matters straightened out. Specifically: (1) In one of my previous postings, I offered biblical quotes (K&R-2) to support my contention that the compiler was misbehaving. Dave Anderson pointed out that doing so was wrong (albeit a common mistake), and that the standard is now the only proper arbiter of correct behaviour. Henry backed this up, saying: | your correspondent is correct in saying that nothing short of the | actual standard is authoritative on the fine points. K&R2 not only made no | attempt to be authoritative, but is wrong in small things due to having | been written based on a late draft rather than the final standard. (2) At one point, I asserted that Since the incrementing of an operand (after noting its value) is part of the definition of the semantics of the postfix ++ operator, it seems quite clear that postfix incrementing has to be treated as an atomic operation. Wrongo. Henry offers a correction: | There has never been any promise that postfix ++ was atomic, and indeed | some compilers do postpone the increment a little in some circumstances. Oh, well, it just goes to prove that no matter how cocky and self-confident I seem to be, there'll always be an opportunity to embarrass myself in public with a mistake or two, even when I'm right! :-) Mark Bartelt 416/978-5619 Canadian Institute for mark@cita.toronto.edu Theoretical Astrophysics mark@cita.utoronto.ca