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 produces a wrong executable code


Description:
------------
Here is a very simple program, for wich gcc produces a wrong executable.
It calulates two number in two different ways. The results should be the
same but 
are different.

The program:
------------

/* beginning of ooop.c */
/* calculate   2.0*1804289383.0/2147483647.0 - 1.0   in two ways */
int main()
{
	double r;
	double d, d1, d2;
	r = 1804289383.0; 

	/* in two steps */
	d1 = 2.0*r/2147483647.0;
	d2 = d1 - 1.0;

	/* at ones */
	d  = 2.0*r/2147483647.0 - 1.0;

	/* Check if d2 == d. */
	if (d2 != d) {
		return (1); /* ooops, not equal ???!!! */
	}
	else {
		return (0); /* the correct result */
	}
}
/* end of ooops.c */



Information:
------------
- compiled with no arguments: if the file is named ooops.c, then just
  gcc ooops.c
  The compiler does not produce any error or warning (even with -Wall)
messages.
  gcc installed using standard RedHat distributions (6.2 and 7.0 - see
bellow)

- problem tested and observed on the following systems:

      * gcc version 2.96 20000731 (Red Hat Linux 7.0)
        Double processor (Intel Pentium III 450MHz) Dell machine with
256M RAM
        Linux 2.2.16 SMP i686 unknown
        GNU ld version 2.10.90 (with BFD 2.10.0.18)
        program is linked with /lib/libc-2.1.92.so and /lib/ld-2.1.92.so
        GNU assembler version 2.10.90 (i386-redhat-linux) using BFD
version 2.10.0.18
        RedHat Linux distribution 7.0

      * gcc version egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)
        Double processor (Intel Pentium III 700MHz) Dell machine with
256M RAM
        Linux 2.2.16 SMP i686 unknown
        GNU ld version 2.9.1 (with BFD 2.9.1.0.24)
        program is linked with /lib/libc-2.1.3.so and /lib/ld-2.1.3.so
        GNU assembler version 2.9.1 (i386-redhat-linux), using BFD
version 2.9.1.0.24
        RedHat Linux distribution 6.2

      * gcc version egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)
        Single processor (Intel Pentium 233MHz) Dell machine with 64M
RAM
        Linux 2.2.14 i586 unknown
        GNU ld version 2.9.1 (with BFD 2.9.1.0.24)
        program is linked with /lib/libc-2.1.3.so and /lib/ld-2.1.3.so
        GNU assembler version 2.9.1 (i386-redhat-linux), using BFD
version 2.9.1.0.24
        RedHat Linux distribution 6.2
 


-- 
___________________________________________________________
Vardan Akopian
University of Southern California
Department of Mathematics
1042 W. 36th Place, DRB 155
Los Angeles, CA 90089-1113
e-mail : vakopian@scf.usc.edu
www :    http://www-scf.usc.edu/~vakopian/

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