[Scummvm-devel] Wii & Gamecube (resp. PowerPC) vs. unaligned memory access

Andre Heider a.heider at gmail.com
Fri May 6 19:43:41 CEST 2011


On Fri, May 6, 2011 at 7:20 PM, Marcus Comstedt <marcus at mc.pp.se> wrote:
>
> Andre Heider <a.heider at gmail.com> writes:
>
>> Confusing? Yes. But reading "return *(const uint32 *)(ptr);" makes me
>> wonder if need_memalign has a confusing name in the first place. If I
>> read GCC's manpage about -fstrict-aliasing right, that may also be
>> undefined behaviour.
>
> If there is code in the same function which writes to whatever ptr
> points to, then the behaviour can be undefined behaviour, yes (the
> order of the read and write operations may be changed by the
> compiler).  Aliasing only matters when you have write accesses.  I'm
> assuming most of the unaligned stuff is about reading from constant
> game data, yes?

Since the READ/WRITE functions are just doing that cast+dereference
and they're marked as (forced) inline I don't know if that rule
applies.

Regards,
Andre




More information about the Scummvm-devel mailing list