• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Odd GCC Behavior
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

References: 
 >Odd GCC Behavior (From: "J. Aaron Pendergrass" <email@hidden>)
 >Re: Odd GCC Behavior (From: Andrew Pinski <email@hidden>)

  • Prev by Date: Re: Odd GCC Behavior
  • Next by Date: Re: Odd GCC Behavior
  • Previous by thread: Re: Odd GCC Behavior
  • Next by thread: Re: Odd GCC Behavior
  • Index(es):
    • Date
    • Thread