[lkml]   [1999]   [Aug]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: WARNING: GCC 2.9.5 & Linux (Horst von Brand)  wrote on 02.08.99 in <>:

> Steve Dodd <> said:
> [...]
> > What /is/ the issue with the strict aliasing code? I was under the
> > impression that it "merely" screwed up code that did icky things with
> > pointers to members of unions. Comments made here about Linus' view on
> > the thing sounds like it is some horrendous problem that may never get
> > sorted. Which is the case?
> The ANSI C standard prohibits accessing data through a pointer to a
> different type. I.e., this is wrong:
> int *pi = ...;
> char *pc;
> pc = (char *) pi;
> *pi = 117; /* 1st */
> *pc = 'a'; /* 2nd */
> ... *pi ... /* 3rd: Illegal */
> Note that 3rd is illegal because we stored there through pc, an char * and
> we are going to access it again at 3rd through a int *. It is fine (AFAIU)
> if you store a char though pc and access it as a char later. The point is
> that this is _hard_ (probably impossible in the general case) to detect for
> a compiler, so the compiler is allowed to assume that *pi does not change,
> since no accesses through an int * could have changed *pi. So it could
> reorder stuff so that the setting at 2nd is done _after_ the line marked
> 3rd above...

Nearly. Except it's defined to be ok if one of your two pointers is a
char* pointer, so your example doesn't work. Try int* and short*, for

MfG Kai

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
Please read the FAQ at

 \ /
  Last update: 2005-03-22 13:53    [W:0.054 / U:0.488 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site