From mboxrd@z Thu Jan 1 00:00:00 1970 From: Scott Wood Date: Fri, 11 Sep 2009 13:28:02 -0500 Subject: [U-Boot] [PATCH] board/flagadm/flash.c: fix compile warning In-Reply-To: <20090911181058.1BC89832E864@gemini.denx.de> References: <1252660703-15596-1-git-send-email-wd@denx.de> <1252660703-15596-3-git-send-email-wd@denx.de> <20090911163321.GB13783@b07421-ec1.am.freescale.net> <20090911181058.1BC89832E864@gemini.denx.de> Message-ID: <4AAA96B2.7020607@freescale.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Wolfgang Denk wrote: > Dear Scott Wood, > > In message <20090911163321.GB13783@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