[Bug target/27627] __builtin_nanf("") doesn't return a _quiet_ nan on parisc
soete dot joel at tiscali dot be
gcc-bugzilla@gcc.gnu.org
Wed May 17 08:56:00 GMT 2006
------- Comment #5 from soete dot joel at tiscali dot be 2006-05-17 08:56 -------
Created an attachment (id=11481)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=11481&action=view)
just another similar test case regarding double equivalent pb
compile with -O2 the Nan3.s is:
.LEVEL 1.1
.section .rodata.str1.4,"aMS",@progbits,1
.align 4
.LC1:
.stringz"__builtin_nan(): 0x%llx.\n"
.section .rodata.cst8,"aM",@progbits,8
.align 8
.LC0:
.word 2146959360
.word 0
.text
.align 4
.globl main
.type main, @function
main:
.PROC
.CALLINFO FRAME=0,CALLS,SAVE_RP
.ENTRY
stw %r2,-20(%r30)
ldil LR'.LC0,%r28
ldil LR'.LC1,%r26
ldw RR'.LC0(%r28),%r23
ldw RR'.LC0+4(%r28),%r24
ldo RR'.LC1(%r26),%r26
ldw -20(%r30),%r2
bl printf,%r0
nop
nop
.EXIT
.PROCEND
.size main, .-main
.ident "GCC: (GNU) 4.1.1 20060511 (prerelease) (Debian 4.1.0-4)"
and print out:
__builtin_nan(): 0x7ff8000000000000.
or bin form of 1 32bit word: 01111111111110000000000000000000
i.e.
- the first bit being the sign == 0
- next 11 being the exponenent all == 1
- next 52 one being fraction have the first bit == 1, making this NAN a
signaling NAN.
And according to this thread (I don't have access to C99 std ;-( ):
<http://gcc.gnu.org/ml/libstdc++/2002-09/msg00030.html>
as well as gcc info
/quote
-- Built-in Function: double __builtin_nan (const char *str)
This is an implementation of the ISO C99 function `nan'.
Since ISO C99 defines this function in terms of `strtod', which we
do not implement, a description of the parsing is in order. The
string is parsed as by `strtol'; that is, the base is recognized by
leading `0' or `0x' prefixes. The number parsed is placed in the
significand such that the least significant bit of the number is
at the least significant bit of the significand. The number is
truncated to fit the significand field provided. The significand
is forced to be a quiet NaN.
This function, if given a string literal, is evaluated early enough
that it is considered a compile-time constant.
/quote
__builtin_nan[f](""); should return a quiet NAN. To do so, the parisc2.0 doc,
says that the fraction part have to be <> 0 but with first bit == 0.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27627
More information about the Gcc-bugs
mailing list