Device/Release version performs differently from others

I'm on iPhone game dev. Here is a strange issue I met, when the game starts, all boxes will fall down and stop on ground if I build in simulator for both debug/release
and in device for debug, but when I build it in device for release, the boxes fall down and seems have a collision to ground, and then keep falling down below the ground,
which made me messed up.
Any help will be appreciated.
Attachment:
Untitled picture.png
Untitled picture.png [ 9.82 KiB | Viewed 659 times ]
Bad behavior in release mode sometimes indicates an uninitialized variable.
Check your optimization level, too - Box2d has problems when running on the actual phone if you enable O3 opts, so make sure you aren't doing so.

I suspect there's a bug somewhere in gcc's optimizer for ARM targets, but I've never really looked into it, I just know that O3 can screw things up.
ewjordan wrote:
Check your optimization level, too - Box2d has problems when running on the actual phone if you enable O3 opts, so make sure you aren't doing so.

I suspect there's a bug somewhere in gcc's optimizer for ARM targets, but I've never really looked into it, I just know that O3 can screw things up.

Thanks jordan, I have the same problem, and solved it by changing the -O3 to -Os.
No problem, happy to help.

This has come up several times before, at some point it would be great to really pin down exactly what's screwing up -O3 opts on the iPhone, and figure out whether it's a Box2d issue or a gcc bug. I can't find any reported bugs on this topic (most of the gcc floating point "bugs" involve equality comparisons between floating point values, which is something you should almost never do), so if it's related to the compiler they should probably know about it, because something seriously wrong is happening.

I've got no ideas, though...everything in Box2d these days seems to be proper standards-compliant C++ these days, I think all the uninitialized variable issues have been gone for quite a while now...

Original thread: https://box2d.org/forum/viewtopic.php?t=5519