From: Robert A Duff <bobduff@shell01.TheWorld.com>
Subject: Re: Pascal Calling Convention
Date: Fri, 25 Mar 2011 12:04:33 -0400
Date: 2011-03-25T12:04:33-04:00 [thread overview]
Message-ID: <wccd3lf5gq6.fsf@shell01.TheWorld.com> (raw)
In-Reply-To: lnipv89vg7.fsf@nuthaus.mib.org
Keith Thompson <kst-u@mib.org> writes:
> Dennis Lee Bieber <wlfraed@ix.netcom.com> writes:
>> i = 0;
>> someC(i++, i++, i++);
> On my system, it produced (2, 1, 0), but this doesn't mean anything.
> In C, the order of evaluation of function arguments is explicitly
> unspecified. Furthermore, in this particular case, the multiple
> modifications to the same object without an intervening sequence
> point mean that the behavior of the program is undefined; ...
True, and writing code that can cause undefined behavior is generally a
Bad Thing. But it doesn't seem like such a bad thing to deliberately
use undefined behavior when trying to figure out what an implementation
is up to "under the hood". Just don't assume too much -- after all,
the compiler might choose left-to-right order in one case, but not
in another case, for efficiency reasons.
>...it
> could legitimately print "a suffusion of yellow" or cause your
> keyboard to explode.
True, according to the C standard. But I'm pretty sure that there's
some other standard that will prevent it from blowing up my keyboard.
;-)
By the way, when explaining what "undefined behavior" means, why does
everybody choose a spectacular example, like exploding keyboards,
or seg faults? I think the worst thing of all is when undefined
behavior does exactly what you want it to do, leaving a latent
bug that will rear its ugly head years later, when you change
some code totally unrelated to the bug, or upgrade your compiler,
or...
>...(C's "undefined behavior" is very much like
> Ada's "erroneous execution" -- and IMHO C chose a better term to
> describe it.)
"very much like"? Is there any difference at all? (Other than
the fact that C has more of it, I mean.)
I agree on the terms. An even better term, IMHO, would be
"unpredictable behavior".
> Furthermore, the order of evaluation of the argument expressions
> isn't *necessarily* related to the order in which the results are
> pushed onto the stack (assuming there even is a stack).
There must be a stack. But you're right -- parameters might be
passed in registers, or some other way, and there's no reason
to assume that the evaluation order will match the way they're
passed.
- Bob
next prev parent reply other threads:[~2011-03-25 16:04 UTC|newest]
Thread overview: 57+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-23 21:37 Pascal Calling Convention Shark8
2011-03-23 23:25 ` Yannick Duchêne (Hibou57)
2011-03-24 0:24 ` Randy Brukardt
2011-03-24 0:43 ` Yannick Duchêne (Hibou57)
2011-03-24 2:04 ` Shark8
2011-03-25 15:40 ` Yannick Duchêne (Hibou57)
[not found] ` <F8mdnYCca6tRJBfQnZ2dnUVZ_s-dnZ2d@earthlink.com>
2011-03-24 19:20 ` Keith Thompson
2011-03-25 16:04 ` Robert A Duff [this message]
2011-03-25 17:02 ` Hyman Rosen
2011-03-25 17:09 ` Robert A Duff
2011-03-25 17:35 ` Hyman Rosen
2011-03-26 19:51 ` Robert A Duff
2011-03-25 17:51 ` Keith Thompson
2011-03-26 20:46 ` Robert A Duff
2011-03-27 2:24 ` Randy Brukardt
2011-03-28 15:41 ` Adam Beneschan
2011-03-28 19:52 ` Robert A Duff
2011-03-29 2:32 ` Randy Brukardt
2011-03-29 6:06 ` Shark8
2011-03-29 23:45 ` Randy Brukardt
2011-03-29 19:19 ` Robert A Duff
2011-03-30 0:02 ` Randy Brukardt
2011-03-30 12:40 ` Robert A Duff
2011-03-30 19:40 ` Randy Brukardt
2011-03-30 20:56 ` tmoran
2011-03-30 22:34 ` Robert A Duff
2011-03-31 21:00 ` Randy Brukardt
2011-03-28 20:29 ` Hyman Rosen
2011-03-28 21:16 ` Adam Beneschan
2011-03-28 21:26 ` Hyman Rosen
2011-03-28 22:08 ` Adam Beneschan
2011-03-28 23:47 ` Georg Bauhaus
2011-03-29 12:23 ` stefan-lucks
2011-03-29 13:10 ` Hyman Rosen
2011-03-30 13:42 ` Phil Clayton
2011-03-31 7:40 ` Phil Clayton
2011-03-29 2:48 ` Hyman Rosen
2011-03-29 18:30 ` Robert A Duff
2011-03-29 23:25 ` Adam Beneschan
2011-03-30 12:50 ` Robert A Duff
2011-03-30 14:47 ` Adam Beneschan
2011-03-30 18:10 ` Robert A Duff
2011-03-29 3:01 ` Hyman Rosen
2011-03-29 18:22 ` Robert A Duff
2011-03-26 21:30 ` Florian Weimer
2011-03-27 16:18 ` Robert A Duff
2011-03-27 16:38 ` Florian Weimer
2011-03-27 16:56 ` Robert A Duff
2011-03-24 2:15 ` Shark8
2011-03-24 0:38 ` ytomino
2011-03-24 2:23 ` Shark8
2011-03-24 21:29 ` Gautier write-only
2011-03-25 12:47 ` Marco
2011-03-25 15:38 ` Yannick Duchêne (Hibou57)
2011-03-26 8:39 ` ObjectAda [was: Pascal Calling Convention] Gautier write-only
2011-03-26 14:05 ` Marco
2011-03-26 21:58 ` Gautier write-only
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox