Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28706 Discussions

SELECT TYPE statement and parenthesized selector

Harald1
New Contributor II
629 Views

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...

 

0 Kudos
4 Replies
Steve_Lionel
Honored Contributor III
611 Views

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.

0 Kudos
Steve_Lionel
Honored Contributor III
580 Views

I verified with Malcolm Cohen, standard editor, that indeed, if X is polymorphic, so is (X). The text I quoted above supports this.

0 Kudos
Harald1
New Contributor II
569 Views
0 Kudos
Barbara_P_Intel
Employee
556 Views

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.

 

0 Kudos
Reply