Re: Odd GCC Behavior
Re: Odd GCC Behavior
- Subject: Re: Odd GCC Behavior
- From: "Andrew Pinski" <email@hidden>
- Date: Mon, 30 Jun 2008 09:49:40 -0700
On Mon, Jun 30, 2008 at 6:26 AM, Andrew Pinski <email@hidden> wrote:
> This code is undefined as you are acessing and modifying a variable with a
> sequence point inbetween the acess and modification. Try compiling with
> warnings turned on. -Wsequence-point should get you a warning.
More to the point, what is unspecified is the order of execution of sp
= (sp - 1) and the other access of sp. So we could have:
sp = sp - 1;
*(sp - 2) += *(sp)
or
*(sp - 2) += *(sp);
sp = sp -1 ;
or even:
tmp = sp -1;
(sp - 2) += (*tmp);
sp = tmp;
So with this case, you get an undefined behavior because of the access.
Thanks,
Andrew Pinski
_______________________________________________
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