http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48979

--- Comment #12 from Tobias Burnus <burnus at gcc dot gnu.org> 2011-05-13 
09:42:02 UTC ---
(In reply to comment #11)
> Mind the change between F2003 and F2008:
> F2003:
> FRACTION(+Inf) = +Inf
> 
> F2008:
> FRACTION(+Inf) = NaN

See http://j3-fortran.org/doc/year/07/07-200r1.txt for that change (cf. also
http://www.j3-fortran.org/doc/meeting/186/08-287r2.txt ).

However, I think it makes sense to stick to the F2008 value - and ignore F2003.


+  if (mpfr_nan_p (x->value.real) != 0 || mpfr_inf_p (x->value.real) != 0)
+    {
+      mpfr_set (result->value.real, x->value.real, GFC_RND_MODE);
+      if (gfc_option.allow_std & (GFC_STD_F2008|GFC_STD_F2003))
+         return result;
+      return range_check (result, "FRACTION");
+    }
+

Regarding the coding:
* if (gfc_option.allow_std & (GFC_STD_F2008|GFC_STD_F2003))
  Better: "gfc_option.allow_std & GFC_STD_F2003)" - later standards imply
  earlier ones.
* mpfr_set (result->value.real, x->value.real, GFC_RND_MODE);
  Better: mpfr_set_nan (result->value.real);


I still miss that -frange-check is mentioned in the error messages produced by
range_check() - and I am not really convinced that (a) the error should be
conditional on -std=f95 and (b) that having a -frange-check enabled by default
is a bad idea. I think many code problems have been found that way - and if the
flag is mentioned in the error message, those few codes which need it, can
simply disable the check.


Side note: If I understand F2003/F2008's IEEE support correctly (that's a big
if): You need to have IEEE_EXCEPTIONS or IEEE_ARITHMETIC loaded *in the scoping
unit*, if you want to use IEEE 754 features. Additionally, a query for
IEEE_SUPPORT_INF and/or IEEE_SUPPORT_NAN had to return .true. in order that
those can be expected to be supported. In that sense: As the program does not
load a IEEE module, it cannot use NAN/INF and the compile-time error is
standard conforming ;-)

Reply via email to