c/412: Re: gcc 2.95.2: Floating point parameter aliasing problems..

Martin v. Loewis martin@loewis.home.cs.tu-berlin.de
Fri Jul 14 00:46:00 GMT 2000


>Number:         412
>Category:       c
>Synopsis:       gcc 2.95.2: Floating point parameter aliasing problems..
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          analyzed
>Class:          wrong-code
>Submitter-Id:   net
>Arrival-Date:   Fri Jul 14 00:46:01 PDT 2000
>Closed-Date:
>Last-Modified:
>Originator:     Jan Vroonhof <jan.vroonhof@insignia.com>
>Release:        2.95.2
>Organization:
>Environment:
>Description:
 Date: 13 Jul 2000 18:53:12 +0100
 Original-Message-ID: <g3aefl9at3.fsf@bart.isltd.insignia.com>
 Lines: 42


 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

>How-To-Repeat:
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the Gcc-prs mailing list