Wolfgang Denk wrote:
> Dear Scott Wood,
> 
> In message <20090911163321.gb13...@b07421-ec1.am.freescale.net> you wrote:
>>> -   ushort * d = (ushort*)&da;
>>> +   ulong *dla = &da;
>>> +   ushort *d = (ushort*)dla;
>> I don't see how this is any more legal under strict aliasing rules -- you
>> just made it a little more complicated and fooled the compiler into not
>> warning.
> 
> Hm... I apologize if I don;t understand this any better, but for me
> silencing the compiler was all that I intended at this moment ;-)

I find that ironic given the previous claim that -fno-strict-aliasing was just 
silencing warnings. :-)

Especially since that actually turned off the problematic language feature 
(which is more intended for number crunching code than device drivers).

Much like your argument in favor of leaving d-cache disabled, this is a 
bootloader -- why complicate it to deal with a fancy compiler optimization that 
isn't going to make any performance difference that matters, could break things 
even in places where GCC doesn't warn, and is easily disabled?

> Do you have any better approach?

union {
        u32 data32;
        u16 data16[2];
} data;

data.data32 = da;

if ((addr[0] & data.data16[0]) != data.data16[0] ||
     (addr[1] & data.data16[1]) != data.data16[1])
        return 2;

etc.

-Scott
_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Reply via email to