This is the mail archive of the 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]
Other format: [Raw text]

[Bug c++/11275] New: gcc296 and gcc322 leads to different double-type calculation results.


           Summary: gcc296 and gcc322 leads to different double-type
                    calculation results.
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++


I isolated a small program from my original program that leads to a double-type
calculation error. 
When I compile the following prgram using gcc296 and gcc322, they produce
different results. I have looked up in the dug database and am awared of the
problem with -O (optimzation) flag (see I re-compiled without
using any optimzation flag. Though it fixed a few calculation errors in my
orignial program, it still produces different results.

======================== my program =================
#include <stdio.h>
#include <math.h>
#include <iostream.h>

void printDouble( double &d)
    char st[100];
    sprintf( st, "%.20f", d);    
    cerr << st << endl;

int main()
    double dS = 0.22683469236471487385;
    double dE = 0.03928836174944403542;
    double iYCount = 86.0;

    double answer = (dS-dE)*log((dS-dE)*iYCount/((iYCount-1.0)*dS)) +
    cerr << "Problem: ";
    printDouble( answer);

    return 1;

============================== my system ===================
My system is RedHat 9.0. 
The compilers that I am using are gcc296 & gcc322

$ gcc296 -v
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux7/2.96/specs
gcc version 2.96 20000731 (Red Hat Linux 7.3 2.96-118)
$ gcc -v
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --enable-shared --enable-threads=posix
--disable-checking --with-system-zlib --enable-__cxa_atexit --host=i386-redhat-linux
Thread model: posix
gcc version 3.2.2 20030222 (Red Hat Linux 3.2.2-5)

========================== compilation step =====================
gcc -lm -lnsl -dl -ltcl -lstdc++ -g -Wall -o main.gcc322

gcc296 -lm -lnsl -dl -ltcl -lstdc++ -g -Wall -o main.gcc296

========================== actual results =======================
$ ./main.gcc296
Problem: 0.07264305087503322711
$ ./main.gcc322
Problem: 0.07264305087503321323

========================== expected results =====================
both printed values should be the same.

Thank you for looking into the problem. Feel free to contact me at or 650-320-2943

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