Re: Odd GCC Behavior
Re: Odd GCC Behavior
- Subject: Re: Odd GCC Behavior
- From: Jonas Maebe <email@hidden>
- Date: Mon, 30 Jun 2008 20:06:14 +0100
On 30 Jun 2008, at 19:32, J. Aaron Pendergrass wrote:
I was somewhat surprised that the "most convenient thing for the
programmer" was something like
"if the left hand of side of a compound assignment statement is a
pointer dereference,
then determine it's r-value first, then evaluate the right hand
side (including any pre/post
increments/decrements), perform the arithmetic for the compound
assignment, then determine the
l-value of the left hand side and perform the actual assignment
otherwise evaluate the left-hand side to determine both its r-value
and l-value, then evaluate the right
hand side (including any pre/post increments/decremetns), perform
the arithmetic for the compound
assignment, then store the result in the previously computed l-
value."
If the standard for a programming language does not define a
particular evaluation order, the compiler usually uses some notion of
complexity to determine what to do first in order to minimize the
register pressure, to minimize the number of instructions required,
etc. (all of which can be processor dependent).
Such optimizations are by no means defined in if-then choices like you
write above, but using some kind of heuristics which have been chosen
based on resulting in good code for a bunch of test cases. Invalid/
undefined code is not commonly considered when writing/evaluating such
heuristics.
Jonas
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden