This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] stdlib/strtod_l.c: Set ERANGE instead of EDOM (BZ #9696)


POSIX 1003.1 says about strtod that if the correct value would cause an
underflow, errno should be set to ERANGE.  The underflow can be caused
by e.g. strtod ("1E-324", NULL).  EDOM is usually set only by math
functions.  Is this OK?

2011-06-22  Marek Polacek  <mpolacek@redhat.com>

        [BZ #9696]
        * stdlib/strtod_l.c (round_and_return): Set ERANGE instead of EDOM.

--- libc/stdlib/strtod_l.c.mp   2011-06-22 19:29:38.369449731 +0200
+++ libc/stdlib/strtod_l.c      2011-06-22 19:38:41.372546071 +0200
@@ -1,5 +1,5 @@
 /* Convert string representing a number to float value, using given locale.
-   Copyright (C) 1997,1998,2002,2004,2005,2006,2007,2008,2009,2010
+   Copyright (C) 1997,1998,2002,2004,2005,2006,2007,2008,2009,2010,2011
    Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -185,7 +185,7 @@ round_and_return (mp_limb_t *retval, int
 
       if (shift > MANT_DIG)
        {   
-         __set_errno (EDOM);
+         __set_errno (ERANGE);
          return 0.0;
        } 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]