Bug 11914 - comparing doubles
Summary: comparing doubles
Status: RESOLVED DUPLICATE of bug 323
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 3.2.2
: P2 normal
Target Milestone: 3.4.0
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-08-14 05:23 UTC by birger.b
Modified: 2005-07-23 22:49 UTC (History)
1 user (show)

See Also:
Host: i386-redhat-linux
Target: i386-redhat-linux
Build: i386-redhat-linux
Known to work:
Known to fail:
Last reconfirmed:


Attachments
Preprocessed source code exp.i (231 bytes, text/plain)
2003-08-14 05:24 UTC, birger.b
Details

Note You need to log in before you can comment on or make changes to this bug.
Description birger.b 2003-08-14 05:23:13 UTC
Overview Description: More detailed expansion of summary.

Drag-selecting any page crashes Mac builds in NSGetFactory

Steps to Reproduce: 
Compile and run

Actual Results:
Program's output:
shouldn't be here
ok!
ok!

Expected Results:
ok!
ok!
ok!

Build Date & Platform:
[lee@yavin strange]$ 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)


Additional Builds and Platforms:
On sparc-sun-solaris2.6 the output is also not as expected but not
the same as on Linux:
Reading specs from /usr/local/lib/gcc-lib/sparc-sun-solaris2.6/2.95.2/specs
gcc version 2.95.2 19991024 (release)

Program's output:
ok!
shouldn't be here
ok!

The following is the *.i file:
# 1 "exp.c"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "exp.c"
int printf(const char *format, ...);

double two = 2;
double five = 5;


const double f() {
        return five;
}

int main () {
# 21 "exp.c"
        if(two/f() == two/f()) {
                printf("ok!\n");
        }
        else {
                printf("shouldn't be here\n");
        }






  if((long double)two/f() == two/f()){
                printf("ok!\n");
        }
        else {
                printf("shouldn't be here\n");
        }






        if(two/five == two/five){
                printf("ok!\n");
        }
        else {
                printf("shouldn't be here\n");
        }
        return 0;
}
Comment 1 birger.b 2003-08-14 05:24:46 UTC
Created attachment 4602 [details]
Preprocessed source code exp.i
Comment 2 Christian Ehrhardt 2003-08-14 07:28:43 UTC
Though often reported this is not a bug. See the section
titled "Problems with floating point computations." on 
http://gcc.gnu.org/bugs.html.


*** This bug has been marked as a duplicate of 323 ***