misc/94583: std::isnan()/std::isinf() are not identical to isnan()
and isinf()
Tom Russo
tvrusso at sandia.gov
Fri Mar 17 03:30:18 UTC 2006
>Number: 94583
>Category: misc
>Synopsis: std::isnan()/std::isinf() are not identical to isnan() and isinf()
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Fri Mar 17 03:30:16 GMT 2006
>Closed-Date:
>Last-Modified:
>Originator: Tom Russo
>Release: FreeBSD 5.4 STABLE
>Organization:
Sandia National Laboratories
>Environment:
FreeBSD xxxxxxx.xxxxxx.xxx 5.4-STABLE FreeBSD 5.4-STABLE #1: Thu Oct 20 02:35:11 MDT 2005 root@:/usr/obj/usr/src/sys/WINSTON i386
>Description:
Discovered that a C++ program that was written to use "std::isnan()" and "std::isinf()" entered an infinite loop with 100% processor activity upon encountering either of these calls.
The attached test program, which was originally written to use "using namespace std;" and no "std::" namespace specification on isnan/isinf worked just fine. Upon adding the namespace specification to isnan and/or isinf, even the test program hung immediately.
While writing the "how to repeat" part of this problem report I discovered that if I specify any optimization level other than -O2 the code segfaults rather than entering an infinite loop.
>How-To-Repeat:
Compile the following test program:
#include <iostream>
#include <cmath>
int main(void)
{
double finite = 1.0e-100;
double infinity = 1.0/0.0;
double nan = sqrt(-1.0);
double minusinfinity = -1.0/0.0;
std::cout << std::endl << "finite = " << finite << std::endl;
std::cout << "isinf() = " << isinf(finite) << std::endl;
std::cout << "isnan() = " << isnan(finite) << std::endl;
std::cout << "isinf() = " << std::isinf(finite) << std::endl;
std::cout << "isnan() = " << std::isnan(finite) << std::endl;
return 0;
}
using g++ 3.4:
g++ -O2 -g -o bugreport bugreport.cpp
Run the resulting executable.
Compiling with -O0 or -O1 results in a segfault instead.
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-bugs
mailing list