Behavior of ELEMENTAL function with VALUE attribute

N.M. Maclaren nmm1@cam.ac.uk
Wed Nov 6 16:34:00 GMT 2013


On Nov 6 2013, FX wrote:

> (As you can guess if you follow my various posts here and on bugzilla, 
> I've taken part of the day to try and write a proof-of-concept patch 
> adding support for the IEEE modules in gfortran. This is the latest 
> sticking point.)
>
> Some of the IEEE functions are elemental. I have a working implementation 
> of them, but I thought it would be nicer to have them take arguments by 
> value. However, things are not behaving as I expected them to. Let's take 
> this code:
>
> Is it, as I think, a bug in gfortran? Or am I missing something deeper 
> about the interaction of ELEMENTAL and VALUE?

Well, sort-of.  It may appear nicer to allow them to be VALUE, but that
is a semantic inconsistency in IEEE 754 itself.  Even simple data copying
by value is NOT guaranteed to be a representation-preserving operation.
A clear example of this is if the value is a signalling NaN - a value
copy may well set the invalid flag and deliver a quiet NaN.


Regards,
Nick Maclaren.



More information about the Fortran mailing list