public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libc/14047] New: strtof gives spurious ERANGE errors
@ 2012-05-02  2:10 bugdal at aerifal dot cx
  2012-05-02 10:47 ` [Bug libc/14047] " joseph at codesourcery dot com
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: bugdal at aerifal dot cx @ 2012-05-02  2:10 UTC (permalink / raw)
  To: glibc-bugs

http://sourceware.org/bugzilla/show_bug.cgi?id=14047

             Bug #: 14047
           Summary: strtof gives spurious ERANGE errors
           Product: glibc
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
        AssignedTo: unassigned@sourceware.org
        ReportedBy: bugdal@aerifal.cx
                CC: drepper.fsp@gmail.com
    Classification: Unclassified


strtof("1.40129846432481707092372958328991613128026194187651577175706828388979108268586060148663818836212158203125e-45",
0) sets errno to ERANGE (presumably considering this an underflow condition),
despite the fact that exact denormal results are specified not to be considered
an underflow. (The decimal string is the exact value of 0x1p-149, the smallest
positive single precision float.)

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug libc/14047] strtof gives spurious ERANGE errors
  2012-05-02  2:10 [Bug libc/14047] New: strtof gives spurious ERANGE errors bugdal at aerifal dot cx
@ 2012-05-02 10:47 ` joseph at codesourcery dot com
  2012-05-02 15:10 ` bugdal at aerifal dot cx
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: joseph at codesourcery dot com @ 2012-05-02 10:47 UTC (permalink / raw)
  To: glibc-bugs

http://sourceware.org/bugzilla/show_bug.cgi?id=14047

--- Comment #1 from joseph at codesourcery dot com <joseph at codesourcery dot com> 2012-05-02 10:46:40 UTC ---
It's not clear to me if this should set errno to ERANGE or not.  IEEE 
754-2008 (section 7.5) says:

  In addition, under default exception handling for underflow, if the 
  rounded result is inexact - that is, it differs from what would have been 
  computed were both exponent range and precision unbounded - the underflow 
  flag shall be raised and the inexact (see 7.6) exception shall be 
  signaled. If the rounded result is exact, no flag is raised and no inexact 
  exception is signaled. This is the only case in this standard of an 
  exception signal receiving default handling that does not raise the 
  corresponding flag. Such an underflow signal has no observable effect 
  under default handling.

So does ERANGE for underflow correspond to the underflow exception being 
signaled (in which case errno should be set to ERANGE) or to the flag 
being raised (in which case errno should not be set to ERANGE)?  I'll see 
what the WG14 reflector thinks.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug libc/14047] strtof gives spurious ERANGE errors
  2012-05-02  2:10 [Bug libc/14047] New: strtof gives spurious ERANGE errors bugdal at aerifal dot cx
  2012-05-02 10:47 ` [Bug libc/14047] " joseph at codesourcery dot com
@ 2012-05-02 15:10 ` bugdal at aerifal dot cx
  2012-05-02 15:27 ` joseph at codesourcery dot com
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: bugdal at aerifal dot cx @ 2012-05-02 15:10 UTC (permalink / raw)
  To: glibc-bugs

http://sourceware.org/bugzilla/show_bug.cgi?id=14047

--- Comment #2 from Rich Felker <bugdal at aerifal dot cx> 2012-05-02 15:09:43 UTC ---
The language you cited seems self-contradictory, unless I'm missing some
context. First it says that in the case we're interested in, "no flag is raised
and no inexact exception is signaled." Then it goes on to talk about how this
case is (pardon the pun) exceptional and about "an exception signal receiving
default handling that does not raise the corresponding flag". I don't
understand at all why the second half of that was written and what it's
intended to mean.

With that said, I think the condition "no observable effect under default
handling" would be contradicted by decimal-string-to-float conversion returning
an indication of underflow.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug libc/14047] strtof gives spurious ERANGE errors
  2012-05-02  2:10 [Bug libc/14047] New: strtof gives spurious ERANGE errors bugdal at aerifal dot cx
  2012-05-02 10:47 ` [Bug libc/14047] " joseph at codesourcery dot com
  2012-05-02 15:10 ` bugdal at aerifal dot cx
@ 2012-05-02 15:27 ` joseph at codesourcery dot com
  2012-05-03 11:14 ` joseph at codesourcery dot com
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: joseph at codesourcery dot com @ 2012-05-02 15:27 UTC (permalink / raw)
  To: glibc-bugs

http://sourceware.org/bugzilla/show_bug.cgi?id=14047

--- Comment #3 from joseph at codesourcery dot com <joseph at codesourcery dot com> 2012-05-02 15:26:47 UTC ---
As I understand it, the point of this case is that if you'd enabled 
trapping on underflow exceptions, your trap handler would be called, but 
without trapping enabled, this case will not set the underflow flag for 
later testing of whether the flag is set.  But for all other cases of 
exceptions, the circumstances when a trap handler would be called when 
trapping is enabled are exactly the circumstances the flag would be set.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug libc/14047] strtof gives spurious ERANGE errors
  2012-05-02  2:10 [Bug libc/14047] New: strtof gives spurious ERANGE errors bugdal at aerifal dot cx
                   ` (2 preceding siblings ...)
  2012-05-02 15:27 ` joseph at codesourcery dot com
@ 2012-05-03 11:14 ` joseph at codesourcery dot com
  2012-10-30 13:53 ` jsm28 at gcc dot gnu.org
  2014-06-25 11:09 ` fweimer at redhat dot com
  5 siblings, 0 replies; 7+ messages in thread
From: joseph at codesourcery dot com @ 2012-05-03 11:14 UTC (permalink / raw)
  To: glibc-bugs

http://sourceware.org/bugzilla/show_bug.cgi?id=14047

--- Comment #4 from joseph at codesourcery dot com <joseph at codesourcery dot com> 2012-05-03 11:14:42 UTC ---
Jim Thomas confirms underflow does mean inexact underflow (flag raised), 
so this is indeed a bug.  Also, as strtod is an operation producing a 
binary result it should be consistent with the architecture-specific 
choice of whether underflow is detected before or after rounding (for 
round-to-nearest, the architecture-specific cases will those at least 
three quarters of the way from the largest subnormal to the smallest 
normal).

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug libc/14047] strtof gives spurious ERANGE errors
  2012-05-02  2:10 [Bug libc/14047] New: strtof gives spurious ERANGE errors bugdal at aerifal dot cx
                   ` (3 preceding siblings ...)
  2012-05-03 11:14 ` joseph at codesourcery dot com
@ 2012-10-30 13:53 ` jsm28 at gcc dot gnu.org
  2014-06-25 11:09 ` fweimer at redhat dot com
  5 siblings, 0 replies; 7+ messages in thread
From: jsm28 at gcc dot gnu.org @ 2012-10-30 13:53 UTC (permalink / raw)
  To: glibc-bugs

http://sourceware.org/bugzilla/show_bug.cgi?id=14047

Joseph Myers <jsm28 at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED

--- Comment #5 from Joseph Myers <jsm28 at gcc dot gnu.org> 2012-10-30 13:52:52 UTC ---
Fixed (including handling both before-rounding and after-rounding architectures
properly) for 2.17 by:

commit 2a27fd6dae3edec949deda9a55928a0e22c8a8ae
Author: Joseph Myers <joseph@codesourcery.com>
Date:   Tue Oct 30 13:51:27 2012 +0000

    Fix strtod handling of underflow (bug 14047).

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug libc/14047] strtof gives spurious ERANGE errors
  2012-05-02  2:10 [Bug libc/14047] New: strtof gives spurious ERANGE errors bugdal at aerifal dot cx
                   ` (4 preceding siblings ...)
  2012-10-30 13:53 ` jsm28 at gcc dot gnu.org
@ 2014-06-25 11:09 ` fweimer at redhat dot com
  5 siblings, 0 replies; 7+ messages in thread
From: fweimer at redhat dot com @ 2014-06-25 11:09 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=14047

Florian Weimer <fweimer at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
              Flags|                            |security-

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-06-25 11:09 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-02  2:10 [Bug libc/14047] New: strtof gives spurious ERANGE errors bugdal at aerifal dot cx
2012-05-02 10:47 ` [Bug libc/14047] " joseph at codesourcery dot com
2012-05-02 15:10 ` bugdal at aerifal dot cx
2012-05-02 15:27 ` joseph at codesourcery dot com
2012-05-03 11:14 ` joseph at codesourcery dot com
2012-10-30 13:53 ` jsm28 at gcc dot gnu.org
2014-06-25 11:09 ` fweimer at redhat dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).