Subject: Re: pkg/30106
To: None <taya@netbsd.org, gnats-admin@netbsd.org, pkgsrc-bugs@netbsd.org>
From: Martin Husemann <martin@duskware.de>
List: pkgsrc-bugs
Date: 05/07/2005 14:09:01
The following reply was made to PR pkg/30106; it has been noted by GNATS.
From: Martin Husemann <martin@duskware.de>
To: Shin'ichiro TAYA <taya@ba2.so-net.ne.jp>
Cc: gnats-bugs@netbsd.org, taya@netbsd.org
Subject: Re: pkg/30106
Date: Sat, 7 May 2005 16:08:15 +0200
On Sat, May 07, 2005 at 06:40:37PM +0900, Shin'ichiro TAYA wrote:
> const PRUint32 nanMask[2] = {TX_DOUBLE_HI32_EXPMASK | TX_DOUBLE_HI32_MANTMASK
> const double NaN = *((double*)nanMask);
This code may work by luck, but it is not guaranteed to work. The compiler
will guarantee that the variable nanMask is properly aligned on a 32bit
address, but the double* dereference needs to be aligned on a 64bit address
(speaking of sparc64 systems here).
So depending on declarations of other variables and link order, you will
get working or broken object code.
Now what to do? I think a real fix would be to use HUGE_VAL and NAN from
<math.h> instead of the homegrown constants - if available. The header
refers to ANSI/ISO C standard sections, so I suppose many systems nowadays
will support these constants, and the NSPR maintainers probably will hapilly
accept a change like this.
Martin