[PATCH] Set errno in strtof variants when conversion from double overflows
Corinna Vinschen
vinschen@redhat.com
Fri Dec 16 18:27:00 GMT 2016
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,
Corinna
> -- 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
> > > --- a/newlib/libc/stdlib/strtod.c
> > > +++ b/newlib/libc/stdlib/strtod.c
> > > @@ -1293,9 +1293,14 @@ _DEFUN (strtod, (s00, se),
> > > float
> > > 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;
> > > +#ifndef NO_ERRNO
> > > + if (isinf (retval) && !isinf (val))
> > > + _REENT->_errno = ERANGE;
> > > +#endif
> > > return (float)retval;
> >
> > ^^^^^^^
> > Shouldn't this cast go, now that retval is already float?
> >
> >
> > Corinna
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/newlib/attachments/20161216/e332e31a/attachment.sig>
More information about the Newlib
mailing list