gcc 2.95.2: Floating point parameter aliasing problems..

Jan Vroonhof jan.vroonhof@insignia.com
Thu Jul 13 10:51:00 GMT 2000


On i686 with -O2, gcc 2.95.2 generates an incorrect result on the
following code (which is based on code used in the pow() function of
fdlibm). (strict aliasing was _not_ enabled).


double a(double x, double y)
{


	double y1;    
		 
	y1 = y;		
	(*(int*)& y1 )  = 0;

	return y1;
}

#include <stdio.h>

int main(int argc,char *argv[])
{
    double eps;
    
    eps = a(2.0,-52.0);

    printf("%e",eps);

  return 0;
}

This is the generated assembly for a():

	pushl %ebp
	movl %esp,%ebp
	subl $24,%esp
	xorl %eax,%eax
	movl %eax,-8(%ebp)
	movl %edx,-4(%ebp)  <-- !
	fldl -8(%ebp)
	leave
	ret



More information about the Gcc-bugs mailing list