Re: GCC 4 and strict aliasing
Re: GCC 4 and strict aliasing
- Subject: Re: GCC 4 and strict aliasing
- From: Steve Checkoway <email@hidden>
- Date: Fri, 17 Mar 2006 03:28:46 -0800
Hi,
On Mar 17, 2006, at 1:19 AM, Frederik Slijkerman (FabFilter) wrote:
My apologies if this question has come up before, but I seem to be
unable to turn off the 'strict aliasing' option in GCC 4 / Xcode
2.2. The problem is that with the -O3 option (Optimization =
Fastest in Xcode), strict aliasing is automatically enabled and
there doesn't seem to be a way to turn it off again. I have tried
adding '-fno-strict-aliasing' to the 'Other C Flags' setting in
Xcode but it doesn't seem to have any effect. Inspecting the gcc
command line in the build window shows that it is added to the
command line properly.
I'm compiling an Audio Unit that uses the CoreAudio SDK which I
don't want to change, and there is a strict aliasing issue in
AUElement::RestoreState() that means that the audio unit cannot
properly restore its state. Here are the offending lines:
UInt32 temp = EndianU32_BtoN(*(UInt32 *)p);
entry.value = *(Float32 *)&temp;
p += sizeof(Float32);
The *(Float32 *)&temp expression is compiled incorrectly on the
PowerPC architecture which gives entry.value a random value.
Interestingly enough, on Intel the correct code is produced.
I can't help with gcc, but if you _can_ change the code, then this
should work:
union { UInt32 i; Float32 f; } u;
u.i = EndianU32_BtoN( *(UInt32 *)p );
entry.value = u.f;
p += sizeof(Float32);
Please, please, can someone tell me how I can turn off strict
aliasing while still being able to compile at the -O3 level? Thanks!
Sorry I couldn't be more help.
- Steve
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden