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

Issues with some forms of variable declarations

Harald1
New Contributor II
1,204 Views

Hello,

 

the following 5 subroutines should be all valid Fortran (and are accepted by NAG), but only the first 3 are accepted, while the last 2 are rejected:

subroutine s (x)
  class(*), allocatable :: x(:)
  if (allocated (x)) print *, size (x)
end

subroutine s1 (x)
  class(*)    :: x(:)
  allocatable :: x
  if (allocated (x)) print *, size (x)
end

subroutine s2 (x)
  class(*)    :: x
  dimension   :: x(:)
  allocatable :: x
  if (allocated (x)) print *, size (x)
end

subroutine s3 (x)
  class(*)    :: x
  allocatable :: x
  dimension   :: x(:)
  if (allocated (x)) print *, size (x)
end

subroutine s4 (x)
  class(*)    :: x
  allocatable :: x(:)
  if (allocated (x)) print *, size (x)
end

I get:

% ifx -c ifort-class-arg.f90ifort-class-arg.f90(19): error #6646: ALLOCATABLE or POINTER attribute dictates a deferred-shape-array.   [X]
subroutine s3 (x)
---------------^
ifort-class-arg.f90(28): error #6427: This dummy scalar or array is invalid in this context.   [X]
  allocatable :: x(:)
-----------------^
ifort-class-arg.f90(29): error #7397: The argument of the ALLOCATED inquiry intrinsic function should have the ALLOCATABLE attribute.   [X]
  if (allocated (x)) print *, size (x)
-----------------^
ifort-class-arg.f90(29): error #6830: The argument of the ALLOCATED intrinsic cannot be a constant or an expression.   [X]
  if (allocated (x)) print *, size (x)
-----------------^
ifort-class-arg.f90(29): error #6361: An array-valued argument is required in this context.   [SIZE]
  if (allocated (x)) print *, size (x)
------------------------------------^
compilation aborted for ifort-class-arg.f90 (code 1)

Same with the classic variant.  I think this a compiler issue.

Thanks,

Harald

 

1 Solution
Barbara_P_Intel
Employee
887 Views

Those false error messages are gone with the Fortran compilers that were released last week as 2024.1. Please give them a try.



View solution in original post

0 Kudos
4 Replies
Steve_Lionel
Honored Contributor III
1,192 Views

Yes, this is a compiler bug, albeit one that I find astonishing.

I will also note that the first error message is incorrect in that one can have a POINTER or ALLOCATABLE that is a scalar.

0 Kudos
Barbara_P_Intel
Employee
1,135 Views

Thanks for reporting this. Bug filed, CMPLRLLVM-45454. I'll let you know when it's fixed.



0 Kudos
Barbara_P_Intel
Employee
888 Views

Those false error messages are gone with the Fortran compilers that were released last week as 2024.1. Please give them a try.



0 Kudos
Harald1
New Contributor II
875 Views

Yes, it is fixed.  Thanks!

 

0 Kudos
Reply