[Bug c/17865] New: Bad code generation (using -O2 and -O3) on x86 target when using the listed snippet
davidel at xmailserver dot org
gcc-bugzilla@gcc.gnu.org
Wed Oct 6 18:12:00 GMT 2004
When compiling the simple program below using -O1 and -O{2,3}, you will get
different results.
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define __HI(x) ((int *) &(x))[1]
double test(double v) {
int hi;
hi = __HI(v);
return hi + v;
}
int main(int ac, char **av) {
double v = 2.30912;
if (ac > 1)
v = atof(av[1]);
printf("val=%lf\n", test(v));
return 0;
}
Looking at the code generation you will notice that the offset of the "fildl" is
clearly wrong, being it accessing the uninitialized part of the stack (it should
have been "12(%ebp)"):
test:
pushl %ebp
movl %esp, %ebp
subl $8, %esp
fildl -4(%ebp)
faddl 8(%ebp)
leave
ret
--
Summary: Bad code generation (using -O2 and -O3) on x86 target
when using the listed snippet
Product: gcc
Version: 3.3.2
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: davidel at xmailserver dot org
CC: gcc-bugs at gcc dot gnu dot org
GCC host triplet: 3.3.2
GCC target triplet: 3.3.2
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17865
More information about the Gcc-bugs
mailing list