cast of float to unsigned char bug on ARM with 3.4.5 - when was it fixed?

Sam Ravnborg sam@ravnborg.org
Wed Jan 9 16:29:00 GMT 2008


The following sample code produces different result depending on
the gcc version and target:

gcc version    target           output
3.4.5          i386             n1: 226 n2: -30.33
4.1.2 (RedHat) i386             n1: 226 n2: -30.33
3.4.5          arm-softfloat    n1: 0 n2: -30.33
4.1.1          arm              n1: 226 n2: -30.33

>From the sample code above it is obvious that gcc 3.4.5
on arm-softfloat differs from the rest.

The sample code:
====================
#include <stdio.h>

int main(void)
{
   unsigned char n1;
   float n2;

   n2 = -30.33F;

   n1 = (unsigned char)n2;

   printf("n1: %d n2: %3.2f\n", n1, n2);

  return 0;
}
====================


I have not yet tried with a arm-softfloat gcc > 3.4.5 because Dan Kegel's
crosstool do not have it out-of-the box.

I assume this is a know bug that got fixed in later gcc's.
I have tried searching the gcc bug database with no luck.

Can anyone give a hint of when it was fixed or how I can better look it
up myself?

Thanks in advance,

	Sam



More information about the Gcc-help mailing list