Content-Type: text/plain; charset="iso-8859-1" From: "Kevin B. Hendricks" To: Andreas Schwab , linuxppc-dev@lists.linuxppc.org Subject: Re: asm inline Date: Mon, 2 Dec 2002 09:14:21 -0500 References: <20021202131158.GA2427@ibrium.se> In-Reply-To: MIME-Version: 1.0 Message-Id: <200212020914.21465.kevin.hendricks@sympatico.ca> Sender: owner-linuxppc-dev@lists.linuxppc.org List-Id: Hi, I thought strict-aliasing was only turned on at -O3? It was that way in the past. Did this change for gcc-3.2.X? There seems to be an enormous amount of code that is not strict-aliasing safe (in the JDK, in OpenOffice.org, etc). Is there any warning flag that can be enabled to help find these cases (the OOo source base is simply huge)? My only choise now is to add -fno-strict-aliasing even with the -O2 flags which I did not think I needed. Kevin On December 2, 2002 08:35, Andreas Schwab wrote: > Samuel Rydh writes: > |> Sure, here is a stand alone program that triggers the problem: > |> > |> ---------------------------------------------------------------- > |> > |> #include > |> typedef unsigned long ulong; > |> > |> static __inline__ void st_le32( ulong volatile *addr, ulong val ) > |> { > |> __asm__ ("stwbrx %1,0,%2" : "=m" (*addr) : "r" (val), "r" > |> (addr) ); } > |> > |> int > |> main( int argc, char **argv ) > |> { > |> int b; > |> st_le32( (ulong*)&b, 0 ); > |> testing( b ); > > This violates the aliasing rules. The compiler is free to assume that > st_le32 does not modify b, because you are invoking undefined behaviour. > > Andreas. ** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/