Bug 6133
Summary: | gcc generates wrong code when comparing doubles. | ||
---|---|---|---|
Product: | [Retired] Red Hat Linux | Reporter: | richieb |
Component: | egcs | Assignee: | Nalin Dahyabhai <nalin> |
Status: | CLOSED NOTABUG | QA Contact: | |
Severity: | medium | Docs Contact: | |
Priority: | medium | ||
Version: | 6.0 | ||
Target Milestone: | --- | ||
Target Release: | --- | ||
Hardware: | All | ||
OS: | Linux | ||
Whiteboard: | |||
Fixed In Version: | Doc Type: | Bug Fix | |
Doc Text: | Story Points: | --- | |
Clone Of: | Environment: | ||
Last Closed: | 1999-10-26 18:05:05 UTC | Type: | --- |
Regression: | --- | Mount Type: | --- |
Documentation: | --- | CRM: | |
Verified Versions: | Category: | --- | |
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
Cloudforms Team: | --- | Target Upstream Version: | |
Embargoed: |
Description
richieb
1999-10-20 12:07:57 UTC
First of all, you need to use -ffloat-store in cases like this. If I do so, I always get "Wrong" for the first printf and "OK" for the second (regardless of optimization options, and with either the GCC we ship or the development GCC from egcs.cygnus.com). As for the case where it still prints "Wrong" - that seems to be the result of doing the arithmetic as extendeds rather than doubles. GCC requires you to use intermediate variables such as "t4" in this example - from the GCC manual (gcc.info): Use @samp{-ffloat-store} for such programs, after modifying them to store all pertinent intermediate computations into variables. The problem I have is that on Solaris "gcc" compiles this program correctly and it always works right. My second problem is that the code that has the problem is produced by a compiler that emits C. Anyway, thanks for the suggestions. If you read gcc.info (just before the sentence I quoted, under -ffloat-store), you'll see that the -ffloat-store issues only apply to architectures such as 68k and x86 in which floating point registers are extendeds. On the sparc, floating point registers are doubles. Feel free to take this up with the gcc maintainers at http://egcs.cygnus.com/ but GCC is behaving as documented - it just happens to differ between x86 and sparc. The problem I have is that on Solaris "gcc" compiles this program correctly and it always works right. My second problem is that the code that has the problem is produced by a compiler that emits C. Anyway, thanks for the suggestions. Thanks! |