Bug in CCBReader

Hi,

The marked line of code throws error on release mode, but not on debug (if I disable the optimization on release mode it also works).

float CCBReader::readFloat() {
unsigned char type = this~~>readByte;
switch {
case kCCBFloat0:
return 0;
case kCCBFloat1:
return 1;
case kCCBFloatMinus1:
return~~1;
case kCCBFloat05:
return 0.5f;
case kCCBFloatInteger:
return (float)this->readInt(true);
default:
{
/* using a memcpy since the compiler isn’t
* doing the float ptr math correctly on device.
* TODO still applies in C*+ ? /
float
pF = ;
float f = 0;
memcpy);
this->mCurrentByte*= 4;
return f; <<<<<<<<<=** BAD ACCESS
}
}

I got the same issue several days ago.
Check the post discussing this issue:
http://www.cocos2d-x.org/boards/6/topics/18183?r=22212
Here is how to fix this bug:
https://github.com/cocos2d/cocos2d-x/pull/1967

Jesus Bosch wrote:

Hi,
>
The marked line of code throws error on release mode, but not on debug (if I disable the optimization on release mode it also works).
>
>
float CCBReader::readFloat() {
unsigned char type = this~~>readByte;
>
switch {
case kCCBFloat0:
return 0;
case kCCBFloat1:
return 1;
case kCCBFloatMinus1:
return~~1;
case kCCBFloat05:
return 0.5f;
case kCCBFloatInteger:
return (float)this->readInt(true);
default:
{
/* using a memcpy since the compiler isn’t
* doing the float ptr math correctly on device.
* TODO still applies in C*+ ? /
float
pF = ;
float f = 0;
memcpy);
this->mCurrentByte*= 4;
return f; <<<<<<<<<=** BAD ACCESS
}
}

Thanks for the tip Nichos!