Bug 8949 - numeric_limits<>::denorm_min() and is_iec559 problems.
Summary: numeric_limits<>::denorm_min() and is_iec559 problems.
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: libstdc++ (show other bugs)
Version: 3.2
: P3 normal
Target Milestone: ---
Assignee: Paolo Carlini
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-12-15 06:46 UTC by johnb
Modified: 2003-07-25 17:33 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
test18_2.cpp (321 bytes, application/octet-stream)
2003-05-21 15:17 UTC, johnb
Details

Note You need to log in before you can comment on or make changes to this bug.
Description johnb 2002-12-15 06:46:01 UTC
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.

Release:
gcc version 3.2 20020903 (Red Hat Linux 8.0 3.2-7)

Environment:
Red Hat Linux 8.0

How-To-Repeat:
Compile and run testcase with g++. You`ll see some failed messages.
Comment 1 Paolo Carlini 2002-12-15 10:55:46 UTC
Responsible-Changed-From-To: unassigned->paolo
Responsible-Changed-Why: Analyzed.
Comment 2 Paolo Carlini 2002-12-15 10:55:46 UTC
State-Changed-From-To: open->analyzed
State-Changed-Why: First half (denorm_min()), already fixed for 3.3, it isn't
    a regression and probably the fix will not be backported
    to 3.2.x. Second half (is_iec559), confirmed everywhere as
    a bug in my reading (see 18.2.1.2, 53 and 18.2.1.5, 1),
    easy to patch as soon as the mainline reopens.
Comment 3 Paolo Carlini 2002-12-16 11:56:40 UTC
State-Changed-From-To: analyzed->closed
State-Changed-Why: Fixed for 3.3 and 3.4.
Comment 4 Paolo Carlini 2002-12-16 19:52:40 UTC
From: paolo@gcc.gnu.org
To: gcc-gnats@gcc.gnu.org
Cc:  
Subject: libstdc++/8949
Date: 16 Dec 2002 19:52:40 -0000

 CVSROOT:	/cvs/gcc
 Module name:	gcc
 Changes by:	paolo@gcc.gnu.org	2002-12-16 11:52:38
 
 Modified files:
 	libstdc++-v3   : ChangeLog 
 	libstdc++-v3/testsuite/18_support: numeric_limits.cc 
 	libstdc++-v3/include/std: std_limits.h 
 
 Log message:
 	2002-12-16  Paolo Carlini  <pcarlini@unitus.it>
 	
 	PR libstdc++/8949
 	* include/std/std_limits.h
 	(struct numeric_limits<short>,
 	struct numeric_limits<unsigned short>,
 	struct numeric_limits<int>,
 	struct numeric_limits<unsigned int>,
 	struct numeric_limits<long>,
 	struct numeric_limits<unsigned long>,
 	struct numeric_limits<long long>,
 	struct numeric_limits<unsigned long long>): According
 	to 18.2.1.2,53 and 18.2.1.5,1 is_iec559 shall be false.
 	* testsuite/18_support/numeric_limits.cc: Add test04.
 
 Patches:
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/ChangeLog.diff?cvsroot=gcc&r1=1.1466&r2=1.1467
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/18_support/numeric_limits.cc.diff?cvsroot=gcc&r1=1.18&r2=1.19
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/include/std/std_limits.h.diff?cvsroot=gcc&r1=1.19&r2=1.20
 
Comment 5 Paolo Carlini 2002-12-19 11:44:31 UTC
From: paolo@gcc.gnu.org
To: gcc-gnats@gcc.gnu.org
Cc:  
Subject: libstdc++/8949
Date: 19 Dec 2002 11:44:31 -0000

 CVSROOT:	/cvs/gcc
 Module name:	gcc
 Branch: 	gcc-3_3-branch
 Changes by:	paolo@gcc.gnu.org	2002-12-19 03:44:31
 
 Modified files:
 	libstdc++-v3   : ChangeLog 
 	libstdc++-v3/testsuite/18_support: numeric_limits.cc 
 	libstdc++-v3/include/std: std_limits.h 
 
 Log message:
 	2002-12-19  Paolo Carlini  <pcarlini@unitus.it>
 	
 	PR libstdc++/8949
 	* include/std/std_limits.h
 	(struct numeric_limits<short>,
 	struct numeric_limits<unsigned short>,
 	struct numeric_limits<int>,
 	struct numeric_limits<unsigned int>,
 	struct numeric_limits<long>,
 	struct numeric_limits<unsigned long>,
 	struct numeric_limits<long long>,
 	struct numeric_limits<unsigned long long>): According
 	to 18.2.1.2,53 and 18.2.1.5,1 is_iec559 shall be false.
 	* testsuite/18_support/numeric_limits.cc: Add test04.
 
 Patches:
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.1464.2.1&r2=1.1464.2.2
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/18_support/numeric_limits.cc.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.18&r2=1.18.4.1
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/include/std/std_limits.h.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.19&r2=1.19.4.1