Hello,
I'm running in to problems with calling floating point functions from cmath. They return with either zeros or the argument I passed. Adding optimization seems to fix the problem sometimes. An example that demonstrates the problem:
#include <stdio.h> #include <cmath> int main (int argc, char** argv) { float test = 1.2; printf ("ceil of %.5f is %.5f\n", test, ceil(test) ); float my_pi = 3.14159, hpi = my_pi /2; printf("sin %f = %f\n", hpi, sin(hpi)); printf("cos %f = %f\n", my_pi, cos(my_pi)); return 0; }
compiled using arm-linux-gnueabihf-g++ with
-std=c++0x -mcpu=cortex-a15 -mfloat-abi=softfp -mfpu=neon-vfpv4
gives:
ceil of 1.20000 is 0.00000
sin 1.570795 = 0.000000
cos 3.141590 = 0.000000
I need neon instructions for part of my actual code, and neon only works with softfp. I think that the problem has to do with which eabi I'm using, but i don't what to do about it because I'm cornered into the setup I'm using. When i compile it with -O1 or higher it works in this simple case but causes segfaults in the math library in my more complex project. Does anyone have any ideas? Am i missing something obvious?