From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28355 invoked by alias); 31 Oct 2002 08:46:02 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 28328 invoked by uid 71); 31 Oct 2002 08:46:01 -0000 Date: Thu, 31 Oct 2002 00:46:00 -0000 Message-ID: <20021031084601.28319.qmail@sources.redhat.com> To: nobody@gcc.gnu.org Cc: gcc-prs@gcc.gnu.org, From: Marco Bernardo Subject: Re: c/8395: gcc 2.95.4 and 3.2 generate wrong code for double on intel Reply-To: Marco Bernardo X-SW-Source: 2002-10/txt/msg01315.txt.bz2 List-Id: The following reply was made to PR c/8395; it has been noted by GNATS. From: Marco Bernardo To: Bruce Allen Cc: gcc-gnats@gcc.gnu.org, , , Subject: Re: c/8395: gcc 2.95.4 and 3.2 generate wrong code for double on intel Date: Thu, 31 Oct 2002 09:39:56 +0100 (CET) Dear Bruce, Thanks for your message. >There's nothing wrong here. It's very reasonable for this code to >produce ~10^-16 for double. >The reason is tha the number 1.2 can not be exactly represented as an >IEEE754 floating point number. >The numbers 5 and -6 CAN be exactly represented. I can understand that the problem is related to the IEEE 754 representation. However, let me point out some weaknesses in your argument: 1. If -1.2 does not have an exact representation, why is the value of variable y (i.e. -1.2) correctly displayed through printf? 2. Let us consider the following variant of the program I attached to my report: #include int main(void) { double x, y, z, y_times_z; x = -6.0; y = -1.2; z = 5; y_times_z = y * z; printf("%g %g %g %g %g %g\n", x, y, z, x - y * z, y_times_z, x - y_times_z); return(0); } With respect to the previous version, I added variable y_times_z together with the visualization of y_times_z as well as x - y_times_z. Surprisingly enough, the output is -6 -1.2 5 -2.22045e-16 -6 0 i.e. the correct values are somehow restored. Now, passing through an additional variable like y_times_z is how the target code produced by gcc should be organized, isn't it? If so, then both x - y * z and x - y_times_z should evaluate to 0. Since this is not the case, gcc contains a bug in the way it translates the arithmetical expressions when doubles are involved. In conclusion, I still believe that gcc contains a serious bug on the intel platform, which should hopefully be fixed asap. If the bug is fixed, or you or someone else reading this message is able to point out some flaw in my argument, then my colleagues, my students, and I will be glad to keep using gcc. Best regards, Marco @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ Prof. Marco Bernardo Universita` di Urbino Centro per l'Applicazione delle Scienze e Tecnologie dell'Informazione Piazza della Repubblica 13, 61029 Urbino, Italy Phone: +39-0722-4475 - E-mail: bernardo@sti.uniurb.it Fax: +39-0722-4475 - WWW: http://www.sti.uniurb.it/bernardo/ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@