So, why is the following code invalid? It is (properly?) rejected by
ifort 11.1, I believe because it violates C611 of the F03 FCD: "If the
rightmost part-name is of abstract type, data-ref shall be
polymorphic."
PROGRAM invalid
IMPLICIT NONE
TYPE, ABSTRACT :: foo
INTEGER :: i
END TYPE foo
TYPE, EXTENDS(foo) :: bar
INTEGER :: j
END TYPE bar
TYPE wrapper
CLASS(foo), ALLOCATABLE :: comp
END TYPE wrapper
TYPE(wrapper) :: obj
ALLOCATE(bar :: obj%comp)
END PROGRAM invalid
I can fix this by changing obj to CLASS(wrapper); but why is this
necessary? I would think that if %comp is of abstract type, then
%comp must be polymorphic, not obj. (I.e. C611 should be the
rightmost part-ref, not data-ref.) Pardon my ignorance here; any
thoughts?
Regards,
Jared
Well, actually, no, I can't. Disregard that claim. I think I can do
this, if I make obj allocatable and allocate it, but that gives an ICE
in ifort (reported). But it _should_ be simple to remedy... :)
> So, why is the following code invalid? It is (properly?) rejected by
> ifort 11.1, I believe because it violates C611 of the F03 FCD: "If the
> rightmost part-name is of abstract type, data-ref shall be
> polymorphic."
[code elided]
> I would think that if %comp is of abstract type, then
> %comp must be polymorphic, not obj. (I.e. C611 should be the
> rightmost part-ref, not data-ref.) Pardon my ignorance here; any
> thoughts?
Those two conditions are identical. See the one-line para 2 paras below
C614.
"The type and type parameters, if any, of a data-ref are those of the
rightmost part name."
(And please forgive the superfluous "if any". I tried to get a lot of
those taken out as being redundant and distracting, but the committee
didn't always go along with me.)
--
Richard Maine | Good judgment comes from experience;
email: last name at domain . net | experience comes from bad judgment.
domain: summertriangle | -- Mark Twain
The code looks standard-conforming to me. As Richard Maine
notes, the type-specifier for obj%comp is CLASS(foo), which
is polymorphic.
Bob Corbett
I have passed this on to our development team. The issue ID is DPD200137426
--
Steve Lionel
Developer Products Division
Intel Corporation
Nashua, NH
For email address, replace "invalid" with "com"
User communities for Intel Software Development Products
http://software.intel.com/en-us/forums/
Intel Software Development Products Support
http://software.intel.com/sites/support/
My Fortran blog
http://www.intel.com/software/drfortran