This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
libstdc++/8949: numeric_limits<>::denorm_min() and is_iec559 problems.
- From: johnb at stl dot sarov dot ru
- To: gcc-gnats at gcc dot gnu dot org
- Date: 15 Dec 2002 14:36:41 -0000
- Subject: libstdc++/8949: numeric_limits<>::denorm_min() and is_iec559 problems.
- Reply-to: johnb at stl dot sarov dot ru
>Number: 8949
>Category: libstdc++
>Synopsis: numeric_limits<>::denorm_min() and is_iec559 problems.
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sun Dec 15 06:46:01 PST 2002
>Closed-Date:
>Last-Modified:
>Originator: Eugeny Belov
>Release: gcc version 3.2 20020903 (Red Hat Linux 8.0 3.2-7)
>Organization:
>Environment:
Red Hat Linux 8.0
>Description:
I found some problems with numeric_limits class:
1. In case denormalization is not presented (numeric_limits<>::has_denorm == false) numeric_limits<float;double;long double>::denorm_min() should be equal to corresponding numeric_limits<float;double;long double>::min(). (minimum positive normalized value, see ISO|IEC 14882 14882 "C++" 18.2.1.2(49-51))
As an effect there is:
2. numeric_limits<float;double;long double>::denorm_min()
should be > 0.0 as stated in ISO|IEC 10967-1 "Language Independend Arithmetic" (see also ISO|IEC 14882 "C++" 18.2.1.2(49-51))
3. Possibly I am wrong here, but please look also for is_iec559 member for short,int,long types, it looks that these types shouldn`t have it set to true.
See small testcase attached also.
>How-To-Repeat:
Compile and run testcase with g++. You`ll see some failed messages.
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: text/plain; name="test18_2.cpp"
Content-Disposition: inline; filename="test18_2.cpp"
#include <limits>
#include <cassert>
#include <iostream>
using namespace std;
#define CHK(condition) if (!(condition)) printf ("check for: %s : Failed!\n",#condition);
int main(int, char *[])
{
CHK(0 < numeric_limits<float>::denorm_min());
CHK(0 < numeric_limits<double>::denorm_min());
CHK(0 < numeric_limits<long double>::denorm_min());
if (numeric_limits<float>::has_denorm == denorm_absent)
CHK( numeric_limits<float>::denorm_min() == numeric_limits<float>::min());
if (numeric_limits<double>::has_denorm == denorm_absent)
CHK( numeric_limits<double>::denorm_min() == numeric_limits<double>::min());
if (numeric_limits<long double>::has_denorm == denorm_absent)
CHK( numeric_limits<long double>::denorm_min() == numeric_limits<long double>::min());
CHK(! numeric_limits<short>::is_iec559);
CHK(! numeric_limits<unsigned short>::is_iec559);
CHK(! numeric_limits<int>::is_iec559);
CHK(! numeric_limits<unsigned int>::is_iec559);
CHK(! numeric_limits<long>::is_iec559);
CHK(! numeric_limits<unsigned long>::is_iec559);
return (0);
}