Re: Patch to remove undefined C code

From: Ben Pfaff (pfaffben@msu.edu)
Date: Mon Oct 16 2000 - 16:38:58 EST


Matti Aarnio <matti.aarnio@zmailer.org> writes:

> On Mon, Oct 16, 2000 at 04:55:08PM -0400, Ben Pfaff wrote:
> > Yes. In practice the usual question is whether the compiler will
> > evaluate the operands from left to right or from right to left,
> > but the compiler is within its rights to evaluate the operands in
> > any order it wants.
>
> That depends mainly on question: Does your stack grow up or down ?

No it doesn't. It depends mainly on whether the ABI for the
machine says that arguments are pushed onto the stack in
left-to-right or right-to-left order. You could do either on
x86, for instance, and it has nothing to do with whether the x86
stack grows up or down.

> > > Does this imply that even the evaluation of a function pointer
> > > is itself undefined in terms of ordering?
> >
> > Yes.
>
> For things like lone pointer referral with pre/post inc/dec:
> *p++
> it is well defined, but for things like:
> *p++ + *p
> it is not. (Will the second *p be evaluated before or after *p++
> post-increment ?)

Non sequitur: I see no function pointers being evaluated here.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Mon Oct 23 2000 - 21:00:10 EST