public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: libstdc++/9922: numeric_limits<double>::quiet_NaN() returns 0
@ 2003-03-03 18:42 paolo
  0 siblings, 0 replies; 2+ messages in thread
From: paolo @ 2003-03-03 18:42 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, mail, nobody

Synopsis: numeric_limits<double>::quiet_NaN() returns 0

State-Changed-From-To: open->closed
State-Changed-By: paolo
State-Changed-When: Mon Mar  3 18:42:19 2003
State-Changed-Why:
    This is already fixed for the upcoming 3.3. The changes are
    too invasive to likely appear in a future 3.2.x release.

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=9922


^ permalink raw reply	[flat|nested] 2+ messages in thread

* libstdc++/9922: numeric_limits<double>::quiet_NaN() returns 0
@ 2003-03-03 16:56 mail
  0 siblings, 0 replies; 2+ messages in thread
From: mail @ 2003-03-03 16:56 UTC (permalink / raw)
  To: gcc-gnats


>Number:         9922
>Category:       libstdc++
>Synopsis:       numeric_limits<double>::quiet_NaN() returns 0
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Mon Mar 03 16:56:01 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     mail@Franosch.org
>Release:        gcc 3.2
>Organization:
>Environment:
Suse Linux 8.0
>Description:
Although the i386 architecture has support for NaN and infinity, numeric_limits<double>::quiet_NaN() and numeric_limits<double>::infinity() return 0.


The correct output of the program below would be
inf
nan
It is
0
0
instead.


#include <limits>
#include <iostream>

using namespace std;

int main() {
  cerr << numeric_limits<double>::infinity() << endl;
  cerr << numeric_limits<double>::quiet_NaN() << endl;
}


I know that numeric_limits<double>::has_quiet_NaN is false and therefore, returning any value in numeric_limits<double>::quiet_NaN() would not be a bug in the strict sense. But I'd consider it a serious flaw in implementation. Please fix that, as workarounds are rather ugly.

Thank you.
>How-To-Repeat:
Compile the program above with g++, execute and watch output. 
>Fix:
I don't know enough about implementation details of gcc/libstdc++ across all supported architectures to provide a fix. But changing

__glibcpp_float_quiet_NaN 0.0F

to

__glibcpp_float_quiet_NaN NAN

(in case NAN is defined by <cmath>) should be trivial (same with INFINITY).
>Release-Note:
>Audit-Trail:
>Unformatted:


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2003-03-03 18:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-03-03 18:42 libstdc++/9922: numeric_limits<double>::quiet_NaN() returns 0 paolo
  -- strict thread matches above, loose matches on Subject: below --
2003-03-03 16:56 mail

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).