[Bug c/20445] New: garbage returned when trying to get the second word of a double value

sumii at saul dot cis dot upenn dot edu gcc-bugzilla@gcc.gnu.org
Sat Mar 12 21:18:00 GMT 2005


> gcc -v
Reading specs from /usr/local/lib/gcc-lib/sparcv9-sun-solaris2/3.3.2/specs
Configured with: /usr/local/src/gnu/gcc-3.3.2/configure --enable-languages=c,c+Â¥
+ sparcv9-sun-solaris2
Thread model: posix
gcc version 3.3.2
> cat test.c
#include <stdio.h>

typedef int int32;

void out(int32 i) {
  printf("0x%x¥n", i);
}

double inp(void) {
  return 123.456789;
}

void getlo() {
  double d = inp();
  int32 i = *((int32 *)&d + 1);
  out(i);
}

void gethi() {
  double d = inp();
  int32 i = *(int32 *)&d;
  out(i);
}

int main() {
  gethi();
  getlo();
  return 0;
}
> gcc -m32 -O2 test.c -o test
> ./test
0x405edd3c
0xfbbb3834
> gcc -m32 -O test.c -o test
> ./test
0x405edd3c
0x7ee0b0b

-- 
           Summary: garbage returned when trying to get the second word of a
                    double value
           Product: gcc
           Version: 3.3.2
            Status: UNCONFIRMED
          Severity: critical
          Priority: P2
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: sumii at saul dot cis dot upenn dot edu
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: sparcv9-sun-solaris2
  GCC host triplet: sparcv9-sun-solaris2
GCC target triplet: sparcv9-sun-solaris2


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20445



More information about the Gcc-bugs mailing list