[Scummvm-devel] Broken Sword 2 problem

Willem Jan Palenstijn wjp at usecode.org
Wed Sep 1 14:06:00 CEST 2010


On Wed, Sep 01, 2010 at 02:49:32PM +0300, yotam barnoy wrote:
> Haven't tried your test, but I think that even if it seems to solve
> the problem, it may not be a real solution but an accidental one.
> There's still aliasing going on ie. the struct is in the same memory
> space as the uint32 or whatever we're reading/writing, and apparently
> that's a bad thing for an optimizing compiler.

Hm, I'm not convinced. The only access to that memory is through this
Unaligned32 struct, as far as this code is concerned, so there shouldn't be any
aliasing.

But the __may_alias__ you mention does sound like it would likely be safer.
(And it does work for the example I was trying.) Do you know in which version
of gcc it was added? The oldest one if I have easily available is 4.1.2 and it
works there.

> I'm currently experimenting with using the __may_alias__ gcc attribute
> which one of the gcc guys suggested to me. In other words, using
> __attribute__ ((__packed__, __may_alias__)).


-Willem Jan




More information about the Scummvm-devel mailing list