This is the mail archive of the
gcc-prs@gcc.gnu.org
mailing list for the GCC project.
c++/5132: NaN = 0.0 * HUGE_VAL fails to compile in templates
- From: wwcopt at optonline dot net
- To: gcc-gnats at gcc dot gnu dot org
- Date: Sun, 16 Dec 2001 13:31:04 -0500
- Subject: c++/5132: NaN = 0.0 * HUGE_VAL fails to compile in templates
- Reply-to: wwcopt at optonline dot net
>Number: 5132
>Category: c++
>Synopsis: NaN = 0.0 * HUGE_VAL fails to compile in templates
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: ice-on-legal-code
>Submitter-Id: net
>Arrival-Date: Sun Dec 16 10:36:01 PST 2001
>Closed-Date:
>Last-Modified:
>Originator: wolfgang wander
>Release: 3.1 20011216 (experimental)
>Organization:
none
>Environment:
System: Linux groby 2.4.17-pre5 #39 Sat Dec 8 15:36:51 EST 2001 i686 unknown
Architecture: i686
host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
configured with: ../gcc/configure --enable-long-long --enable-languages=c++,c --prefix=/work/gcc
>Description:
Generating a NaN from 0.0*HUGE_VAL fails with a tree check error
if the expression is inside template code (function or class).
>How-To-Repeat:
Compile the following code with g++ -c bugnan.C
------------------------- bugnan.C ----------------------
// snippets from bits/huge_val.h
#define __HUGE_VAL_bytes { 0, 0, 0, 0, 0, 0, 0xf0, 0x7f }
#define __huge_val_t union { unsigned char __c[8]; double __d; }
#define HUGE_VAL (__extension__ \
((__huge_val_t) { __c: __HUGE_VAL_bytes }).__d)
void
foo( const int&) {
const double nan = 0.0 * HUGE_VAL; // no problem here
}
template <class F>
void
Tfoo( const F&) {
const double nan = 0.0 * HUGE_VAL; // g++ fails here
}
--------------------------
>Fix:
Only workaround is to avoid templates ...
>Release-Note:
>Audit-Trail:
>Unformatted: