Page 1 of 1

NaN values when optimization’s turned on

Posted: Thu Dec 28, 2017 1:46 pm
by jallwine
I recently opened up an old iOS app of mine that uses Chipmunk. It’s running version 6.2.1. The app broke years ago when iOS devices switched to 64 bit CPUs. I use floats throughout my app, which worked fine when CGPoint was a pair of floats. When it became a pair of doubles, I had already stopped working on the project and haven’t touched it since. I’m now trying to get it working again. To get it to work I recompiled Chipmunk with CP_USE_CGPOINTS and CP_USE_DOUBLES set to 0. This all seems to work on my iPhone 6s Plus (a 64 bit device). When I try to run it on my old iPad Mini (a 32 bit device) I see some strange behavior. Positions and velocities become NaN values, but only when I use optimizations to compile Chipmunk (-O1, -O2 or -O3). When -O0 is used, I don’t see the same problems. I’m unsure if I just turned off optimization’s before. I haven’t been able to track down exactly when my data is getting corrupted yet, but wanted to reach out and see if anyone had any insights as to what might be causing this. I am doing some crazy things with changing objects between rogue and static bodies, so it may be something strange I’m doing, but I repeatedly am seeing it work with optimizations off and stop working with them on.