(j3.2006) parameterized derived types
Robert Corbett
robert.corbett
Wed Dec 9 05:11:15 EST 2015
On 12/08/15 22:34, Cohen Malcolm wrote:
> I certainly agree there is a problem here. This is probably more obvious in
> argument association, e.g.
>
> ...
> TYPE(T(5)) x
> CALL ieee_set_rounding_mode(ieee_down)
> CALL sub(x,5)
> ...
> SUBROUTINE sub(y,n)
> TYPE(T(n)) y
>
> As X and Y have the same type and type parameter values, obviously they have
> to have the same layout in memory etc.
>
> Basically, this means that any floating-point expressions in a "component
> specification expression" (making that term up) would have to be evaluated
> with the arithmetic and rounding modes that the processor uses at compile
> time for this to work.
>
> Alternatively we could forbid such code from appearing in component
> specification expressions, or forbid instantiation of such objects when the
> "floating-point environment" means that the values of any such expressions
> would differ. The former seems hard to express without using the big
> hammer of forbidding floating-point in component specification expressions
> altogether, whilst the latter is profoundly user-unfriendly.
>
> Unlike Robert, I do not think the first option would give up "many
> optimization"; there would be little lost if the compiler pessimized such
> expressions.
>
I agree that floating-point subexpressions are so rarely used in specification
expressions that the effect on performance of programs should be negligible.
While it is easy to write test programs that demonstrate the problem, programs
written for practical uses will almost never be affected.
The optimizers and code generators available to my team are likely to produce
code that yields different results for the same floating-point expression in
different contexts even when the rounding mode is not changed. It is possible
to produce intermediate code that nails down the order of evaluation and the
precision of results, but the intermediate code our front-end normally produces
is not so strict.
Robert Corbett
More information about the J3
mailing list