This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

gcc 2.95.2: Floating point parameter aliasing problems..



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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]