Hello,

I'm thinking about how to implement Fortran 2003's IEEE support in
gfortran. The IEEE allow
a) To set an IEEE value (NaN, INF, etc.)
b) Check whether a value is NaN, etc.
c) To query for IEEE capabilities (IEEE_SUPPORT_NAN, IEEE_SUPPORT_SQRT
(a sqrt() which has IEEE exception support), etc.)
d) To query/set haltmodes for DIVIDE_BY_ZERO, INVALID etc.
e) Getting/setting an exception flag, etc.

While (a) and (b) can be easily handled in the front end, I don't see
how I can handle the rest efficiently. Most parts are provided by
fenv.h, for which I seemingly have to write a wrapper function (in
libgfortran) as the typedefs and constants cannot be made available in
the front end - or have I missed something?

My biggest issue is that I don't see how I can compile-time evaluate the
following - or how to evaluate it at all:

if (IEEE_SUPPORT_NAN(x)) &    ! should be always true (or false) on a
given system
   x = IEEE_VALUE(IEEE_QUIET_NAN, x) ! x = qNaN (trivial in the front end).

The Fortran standard lists: IEEE_SUPPORT_DENORMAL, _DIVIDE (by zero),
_INF, _NAN, _SQRT (a sqrt which follows IEEE), _ROUNDING, (and _IO). Is
there some possibility to query the target whether e.g. NaN is supported?

For querying/setting the halting mode, I would work with the data in
libgfortran/config/*.h.

Tobias

Reply via email to