This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
optimization/1762: treatment of NaNs violates IEEE 754
- To: gcc-gnats at gcc dot gnu dot org
- Subject: optimization/1762: treatment of NaNs violates IEEE 754
- From: reichelt at igpm dot rwth-aachen dot de
- Date: 24 Jan 2001 18:54:41 -0000
- Reply-To: reichelt at igpm dot rwth-aachen dot de
>Number: 1762
>Category: optimization
>Synopsis: treatment of NaNs violates IEEE 754
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: unassigned
>State: open
>Class: wrong-code
>Submitter-Id: net
>Arrival-Date: Wed Jan 24 10:56:00 PST 2001
>Closed-Date:
>Last-Modified:
>Originator: Volker Reichelt
>Release: gcc 2.95, 2.96.20000920 on IRIX6.5
>Organization:
>Environment:
SGI O2, IRIX 6.5
CPU: MIPS R5000 Processor Chip Revision: 2.1
FPU: MIPS R5000 Floating Point Coprocessor Revision: 1.0
>Description:
The following program shows some problems with the
treatment of NaNs. According to IEEE 754 the result
of "0 < NaN" should be false. Therefore the result
of "less" and the return value of the program should
be "0". This is the case, if I compile the program
without optimization. With optimization enabled,
however, I get the result "1" instead.
(The same problem arises, when "a<b?b:a" is evaluated.)
double less(double a, double b)
{
return a < b;
}
int main()
{
const double NaN = 0.0/0.0;
return (int)less(0.0,NaN);
}
>How-To-Repeat:
gcc -O1 NaN.cpp; ./a.out; echo $?
(assuming the file is called NaN.cpp)
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted: