This is the mail archive of the
mailing list for the newlib project.
Re: [PATCH] Set errno in strtof variants when conversion from double overflows
On 16/12/16 18:27, Corinna Vinschen wrote:
On Dec 16 11:30, Jeff Johnston wrote:
It can go, but I would imagine it is doing no harm if the compiler has any
smarts at all. I'll remove it.
Yeah, I didn't worry about the compiler, I was just thinking of code
cleanup. Did the same to wcstod.c.
Thanks Jeff and Corinna.
I was testing a patch to delete these, but you beat me to it.
-- Jeff J.
----- Original Message -----
On Dec 15 16:47, Kyrill Tkachov wrote:
diff --git a/newlib/libc/stdlib/strtod.c b/newlib/libc/stdlib/strtod.c
index e908fcb..f82f507 100644
@@ -1293,9 +1293,14 @@ _DEFUN (strtod, (s00, se),
strtof_l (const char *__restrict s00, char **__restrict se, locale_t loc)
- double retval = _strtod_l (_REENT, s00, se, loc);
- if (isnan (retval))
+ double val = _strtod_l (_REENT, s00, se, loc);
+ if (isnan (val))
return nanf (NULL);
+ float retval = (float) val;
+ if (isinf (retval) && !isinf (val))
+ _REENT->_errno = ERANGE;
Shouldn't this cast go, now that retval is already float?