Subject: Re: linux-next: manual merge of the rr tree

From: Andi Kleen <[email-masked]>
Date: Wed, 7 Jan 2009 18:20:51 +0100

> > This one example of gcc making assumptions about pointer arithmetic.  It's
> > perfectly reasonable.  It's also unhelpful cases like for per-cpu offsets.
> 
> What assumption does GCC make that would cause problems?

The C standard says that arithmetic on pointers in defined objects outside
the boundaries of these objects (except for the special case of one beyond 
the end for arrays) is undefined. The gcc optimizers take advantage
of this by assuming that such arithmetic doesn't wrap (and might have other
assumptions)

> 
> > Thus we use this macro to prevent GCC from making such assumptions.
> 
> Never seen any ill effect from just using a pointer recast and add.

One concrete miscompilation has been observed on PPC a couple
of years ago, so it was decided to try to avoid this on all
architectures.
> 
> One issue may be that issue of pointer into an object not being valid if
> they are made to point outside of the object?

"undefined" yes.

-Andi
-- 
[email-masked]