Current-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Cross-building on MacOS X/lint failure

On Mon, Dec 01, 2008 at 11:59:29PM -0600, Eric Haszlakiewicz wrote:
> > This, however, makes no sense to me.  This assignment looks perfectly legal,
> > and it shouldn't be corrupting the pointer value.  I replace this with:
> > 
> >             memcpy(n->tn_val, &sym->s_value, sizeof(val_t));
> > 
> > And I got the same exact corrupted pointer.  Just for the hell of it,
> > I replaced this with a loop copying the memory byte by byte, and it worked.

Recent versions of gcc will treat the memcpy the same as the structure
assignment! This means both 'suffer' from the 'strict aliasing'
The byte by byte copy explicitly avoids any 'strict aliasing' issues
since byte access via aliased pointers is allowed.

If the code is (trying to) access the same memory through different
fields of a union then all is lost :-(

It might also be the same optimisation bug that has been recently
reported elswehere.


David Laight:

Home | Main Index | Thread Index | Old Index