http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60166
Bug ID: 60166 Summary: ARM default NAN encoding violates EABI Product: gcc Version: 4.9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libgcc Assignee: unassigned at gcc dot gnu.org Reporter: joey.ye at arm dot com #include <stdio.h> #include <string.h> #include <math.h> int g; float i = 0.0 ,j = 0.0 ; int main() { float f = i / j; memcpy(&g, &f, sizeof(g)); printf("f=%f, hex=%x\n", f, g); return 0; } When built for ARM thumb1, result is: f=nan, hex=7fffffff While according to the RTABI (http://infocenter.arm.com/help/topic/com.arm.doc.ihi0043d/IHI0043D_rtabi.pdf) section 4.1.1.1: When not otherwise specified by IEEE 754, the result on an invalid operation should be the quiet NaN bit pattern with only the most significant bit of the significand set, and all other significand bits zero. So current libgcc is violating ARM EABI. I have a patch under testing.