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] |
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 functionsBut 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 removalof 'errno != 0' may be appropriate. The test for 'errno != EINVAL' is still a validate test.
ERRORS EINVAL (not in C99) The given base contains an unsupported value.
The implementation may also set errno to EINVAL in case no conversion was performed (no digits seen, and 0 returned).
Index: read.c =================================================================== --- read.c (revision 126739) +++ read.c (working copy) @@ -177,10 +177,10 @@ convert_real (st_parameter_dt *dtp, void internal_error (&dtp->common, "Unsupported real kind during IO"); }
- if (errno != 0 && errno != EINVAL) + if (errno == EINVAL) { generate_error (&dtp->common, ERROR_READ_VALUE, - "Range error during floating point read"); + "Error during floating point read"); return 1; }
[jerry@quasar test]$ ./a.out 0.000000 0.000000 0.000000 0.000000
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |