- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
the following code is accepted by NAG but rejected by ifort/ifx:
program p
type t
integer :: a
end type
contains
subroutine s(x)
class(t) :: x(:)
select type (y => x) ! OK
type is (t)
end select
select type (z => (x)) ! rejected by ifort/ifx
type is (t)
end select
end
end
I get:
% ifx -what ifort-select-type.f90
Intel(R) Fortran 23.0-1769.01
ifort-select-type.f90(11): error #8247: Selector in SELECT TYPE statements must be polymorphic value.
select type (z => (x)) ! rejected by ifort/ifx
----^
compilation aborted for ifort-select-type.f90 (code 1)
Likely a bug...
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I think it is a bug, but a subtle one:
C1164 (R1155) The selector in a select-type-stmt shall be polymorphic.
"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." (F018 10.19.1)
and then:
"If a primary is a parenthesized expression, its type, type parameters, and shape are those of the expression." (F2018 10.1.9.2)
So here, (X) is a parenthesized expression, and the expression is X. X is a polymorphic primary.
I admit to being a bit uncomfortable with this and will check on this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I verified with Malcolm Cohen, standard editor, that indeed, if X is polymorphic, so is (X). The text I quoted above supports this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Since @Steve_Lionel and Malcom concur that this is part of F2018 and should not report an error message, I filed a bug, CMPLRLLVM-52979.
Curiously, gfortran 9.4.0 ICEs.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page