public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/28191] New: double comparisions are broken when value is returned from function
@ 2006-06-28 15:46 rozenman at gmail dot com
2006-06-28 16:02 ` [Bug c/28191] " rozenman at gmail dot com
2006-06-28 18:50 ` pinskia at gcc dot gnu dot org
0 siblings, 2 replies; 3+ messages in thread
From: rozenman at gmail dot com @ 2006-06-28 15:46 UTC (permalink / raw)
To: gcc-bugs
Hi,
This looks like floating point rounding problem but it's not. Please review the
following testcase:
#include <stdio.h>
double func(double p) {
return 1.097986768 * 7654 / 4.567891000000003 + 1/p;
}
int main()
{
double PARAM = 3.0001;
double aVal = func(PARAM);
double bVal = func(PARAM);
if (aVal > bVal) {
printf("1\n");
} else {
printf("0\n");
}
if (func(PARAM) > func(PARAM)) {
printf("1\n");
} else {
printf("0\n");
}
}
Running this program compiled with gcc 4.1.0 (and 4.0.1 as well) prints:
0
1
First answer ("0") is right (X < X == false), but second is wrong.
IMHO it is very serious problem, especially for complicated computional
algorithms.
--
Summary: double comparisions are broken when value is returned
from function
Product: gcc
Version: 4.1.0
Status: UNCONFIRMED
Severity: critical
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: rozenman at gmail dot com
GCC host triplet: Linux tin 2.6.15-1.2054_FC5smp #1 SMP Tue Mar 14
16:05:46 EST 20
GCC target triplet: i686-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28191
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c/28191] double comparisions are broken when value is returned from function
2006-06-28 15:46 [Bug c/28191] New: double comparisions are broken when value is returned from function rozenman at gmail dot com
@ 2006-06-28 16:02 ` rozenman at gmail dot com
2006-06-28 18:50 ` pinskia at gcc dot gnu dot org
1 sibling, 0 replies; 3+ messages in thread
From: rozenman at gmail dot com @ 2006-06-28 16:02 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from rozenman at gmail dot com 2006-06-28 15:46 -------
Created an attachment (id=11769)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=11769&action=view)
Testcase program
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28191
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c/28191] double comparisions are broken when value is returned from function
2006-06-28 15:46 [Bug c/28191] New: double comparisions are broken when value is returned from function rozenman at gmail dot com
2006-06-28 16:02 ` [Bug c/28191] " rozenman at gmail dot com
@ 2006-06-28 18:50 ` pinskia at gcc dot gnu dot org
1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-06-28 18:50 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from pinskia at gcc dot gnu dot org 2006-06-28 18:49 -------
*** This bug has been marked as a duplicate of 323 ***
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |DUPLICATE
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28191
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2006-06-28 18:50 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-06-28 15:46 [Bug c/28191] New: double comparisions are broken when value is returned from function rozenman at gmail dot com
2006-06-28 16:02 ` [Bug c/28191] " rozenman at gmail dot com
2006-06-28 18:50 ` pinskia at gcc dot gnu dot org
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).