public inbox for
help / color / mirror / Atom feed
* optimization/10825: GCC 2.3.2 cannot compare two double
@ 2003-05-16 18:36 lethiec
  0 siblings, 0 replies; only message in thread
From: lethiec @ 2003-05-16 18:36 UTC (permalink / raw)
  To: gcc-gnats; +Cc: guindon

>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
>Originator:     Franck Le Thiec
>Release:        3.2.3
i386-linux 2.4.17
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"
#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));

    { /*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)

no known fixes !

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2003-05-16 18:36 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-05-16 18:36 optimization/10825: GCC 2.3.2 cannot compare two double lethiec

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).