Re: Problem in AUElement::SaveState, conversion from Float32 -> UInt32 not working in non debug mode
Re: Problem in AUElement::SaveState, conversion from Float32 -> UInt32 not working in non debug mode
- Subject: Re: Problem in AUElement::SaveState, conversion from Float32 -> UInt32 not working in non debug mode
- From: Doug Wyatt <email@hidden>
- Date: Thu, 23 Aug 2007 12:56:45 -0700
Are you compiling with -fstrict-aliasing?
If you enable -Wstrict-aliasing do you get a warning?
Doug
On Aug 23, 2007, at 3:10 , Chris wrote:
Hello,
I can't save the state of my AU, because AUElement::SaveState is not
working properly.
I think the issue is a compilation option problem linked to data
alignment.
In debug mode, it's working fine.
In non debug mode, data are not converted properly (mostly result is
zero).
To find out, I added a few lines of code.
I found the *(UInt32*)&v conversion is not working depending on its
alignment.
(see the two examples below, performing two conversion. Always, the
first conversion is failing.
I inverted the conversions between the two trials. Each conversion
is working when it is in second
position).
What can I do??
Thanks,
Chris
AUBase::SaveState
sizeof Float32=4 UInt32=4
AUElement::*(UInt32 *)&v v=103.000000 vi=0 <-- NOK
AUElement::EndianU32_NtoB 103.000000-> 1120796672 <-- OK
void AUElement::SaveState(CFMutableDataRef data)
{
{
printf("sizeof Float32=%ld UInt32=%ld
\n",sizeof(Float32),sizeof(UInt32));
Float32 v = 103.0f;
UInt32 vi = *(UInt32 *)&v;
printf(" AUElement::*(UInt32 *)&v v=%f vi=%ld\n",v,vi);
UInt32 i = EndianU32_NtoB(*(UInt32 *)&v);
printf(" AUElement::EndianU32_NtoB %f-> %ld\n",v,i);
}
...
}
//////////////////////////////////////////////////////
AUBase::SaveState
sizeof Float32=4 UInt32=4
AUElement::EndianU32_NtoB 103.000000-> 0 <--NOK
AUElement::*(UInt32 *)&v v=103.000000 vi=1120796672 <-- OK
void AUElement::SaveState(CFMutableDataRef data)
{
{
printf("sizeof Float32=%ld UInt32=%ld
\n",sizeof(Float32),sizeof(UInt32));
Float32 v = 103.0f;
UInt32 i = EndianU32_NtoB(*(UInt32 *)&v);
printf(" AUElement::EndianU32_NtoB %f-> %ld\n",v,i);
UInt32 vi = *(UInt32 *)&v;
printf(" AUElement::*(UInt32 *)&v v=%f vi=%ld\n",v,vi);
}
...
}
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
@apple.com
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden