(j3.2006) Is a parenthesized polymorphic defined operation a polymorphic primary?
Robert Corbett
robert.corbett
Tue Mar 24 03:10:59 EDT 2015
A user has written a program in which he has used parentheses
to group the operands of an expression that consists of
two applications of a polymorphic defined operation:
O4 = O1 + (O2 + O3)
The operations turn into calls of a function that has a
polymorphic allocatable result variable. Oracle Solaris
Studio Fortran assumes that the parenthesized expression is
not polymorphic, and so considers the dynamic type of the
parenthesized expression to be the same as the declared
type of the function result variable. The user assumes
the dynamic type of the parenthesized expression should
be the same as the dynamic type of the expression without
the parentheses.
Paragraph 2 of Clause 7.1.9.1 of the Fortran 2008 standard
states:
If an expression is a polymorphic primary or
defined operation, the type parameters and the
declared and dynamic types of the expression
are the same as those of the primary or defined
operation.
The question of whether the dynamic type of a parenthesized
expression is the same as the declared type or the dynamic
type of the contained expression depends on whether the
parenthesized expression is considered a polymorphic
primary. The standard does not appear to supply an explicit
answer to that question. Because defining when a
parenthesized expression is polymorphic would require
consideration of the nature of the contained expression
that is not spelled out in the standard, I assume that a
parenthesized expression is not intended to be a
polymorphic primary.
Robert Corbett
More information about the J3
mailing list