This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran 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]

Re: Problem with zeros.


On Thu, Jul 19, 2007 at 08:04:38PM +0200, Tobias Burnus wrote:
> Steve Kargl wrote:
> > libc on FreeBSD isn't glibc. It's probably an implementation 
> > detail of the scanf() family of functions
> But not scanf directly as scanf("%f", float) produces "0.0" and "Inf" on
> my system.
> 
> ... ok, I did not check errno:
> 
> 
>   if (errno != 0 && errno != EINVAL)
>     {
>       generate_error (&dtp->common, ERROR_READ_VALUE,
>                       "Range error during floating point read");
>       return 1;
>     }
> 
> 
> This gives for the denormal numbers and too large numbers:
>    ERRNO = 34, error = Numerical result out of range
> 
> This is ERANGE. I wonder whether one should leave of this ERANGE change?
> 
> POSIX defines it as "Result too large."
> 
> Interestingly, looking at POSIX (or ISO C), for scanf ERANGE is not
> listed as condition under which fscanf() functions fail and may fail.
> These are only EILSEQ, EINVAL and  the onces listed in fgetc/fgetwc.
> 
> Therefore, I would suggest to simply remove either the hole if block or
> to exclude at least ERANGE.

The FreeBSD man page for scanf doesn't enumerate the possble
errno values.  It simply states "... functions conform tor
ISO/IEC 9899:1990 (``ISO C90'')."

>From your description above, it would appear that removal
of 'errno != 0' may be appropriate.  The test for 'errno
!= EINVAL' is still a validate test.
-- 
Steve


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