public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: lethiec@lirmm.fr
To: gcc-gnats@gcc.gnu.org
Cc: guindon@lirmm.fr
Subject: optimization/10825: GCC 2.3.2 cannot compare two double
Date: Fri, 16 May 2003 18:36:00 -0000	[thread overview]
Message-ID: <20030516183217.13040.qmail@sources.redhat.com> (raw)


>Number:         10825
>Category:       optimization
>Synopsis:       GCC 2.3.2 cannot compare two double
>Confidential:   no
>Severity:       critical
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          wrong-code
>Submitter-Id:   net
>Arrival-Date:   Fri May 16 18:36:02 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     Franck Le Thiec
>Release:        3.2.3
>Organization:
>Environment:
i386-linux 2.4.17
>Description:
in a loop a multiple of M_PI is put into two variables,
one is an array of double allocated by malloc
the other is a double.
they compare equal when using gcc with options "-lm" or "-O1 -lm"
they compare different when using gcc with "-O2 -lm" or "-O3 -lm" or "-O4 -lm"
>How-To-Repeat:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(int argc, char **argv)
{
  double *a1,a2;
  int i;

  a1 = (double*)malloc(sizeof(double));
  a1[0]=a2=0.0;

  for(i=1;i<15;i++)
    { /*if we loop until 13 no problem!*/
      a1[0] += M_PI;
      a2 += M_PI;
    }

  printf("%.50f\n%.50f\n",a1[0], a2);
  if (a1[0]==a2)
    printf("equal\n");
  else
    printf("different\n");

  free(a1);
}
>Fix:
no known fixes !
>Release-Note:
>Audit-Trail:
>Unformatted:


                 reply	other threads:[~2003-05-16 18:36 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20030516183217.13040.qmail@sources.redhat.com \
    --to=lethiec@lirmm.fr \
    --cc=gcc-gnats@gcc.gnu.org \
    --cc=guindon@lirmm.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).