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

Failure to simplify some array constructors with SIZE intrinsic

Harald1
New Contributor II
990 Views

Hello,

the following code may be using SIZE in a weird way to compute the shape and size of an array but should be valid Fortran:

program p
  implicit none
  integer :: k
  integer, parameter :: x(2,3) = 1
  integer, parameter :: s(*) = [shape(x)]
  integer, parameter :: t(*) = [(size(x, dim=k), k=1,2)]       ! fail
  integer, parameter :: u(*) = [(size(x, dim=k), k=1,rank(x))] ! fail
  integer, parameter :: v = product(shape(x))
  integer, parameter :: w = product([(size(x, dim=k), k=1,2)]) ! fail
  print *, s
  print *,         [(size(x, dim=k), k=1,rank(x))]
  print *, product([(size(x, dim=k), k=1,rank(x))])
end

With current ifort/ifx I get:

% ifort ifort-size-simplify.f90
ifort-size-simplify.f90(6): error #7747: Invalid parameter expression.
  integer, parameter :: t(*) = [(size(x, dim=k), k=1,2)]       ! fail
---------------------------------^
ifort-size-simplify.f90(7): error #7747: Invalid parameter expression.
  integer, parameter :: u(*) = [(size(x, dim=k), k=1,rank(x))] ! fail
---------------------------------^
ifort-size-simplify.f90(9): error #6063: An INTEGER or REAL data type is required in this context.   [K]
  integer, parameter :: w = product([(size(x, dim=k), k=1,2)]) ! fail
--------------------------------------------------^
compilation aborted for ifort-size-simplify.f90 (code 1)

Commenting the marked code lines allows the code to compile and work as expected.  It is only the simplification of the array constructors needed for the constant expressions above that fails.

Thanks,

Harald

 

1 Solution
Barbara_P_Intel
Employee
935 Views

This reproducer is indeed legal Fortran. I filed a bug report, CMPLRLLVM-48095. I'll let you know when a fix is available.


View solution in original post

0 Kudos
3 Replies
Barbara_P_Intel
Employee
936 Views

This reproducer is indeed legal Fortran. I filed a bug report, CMPLRLLVM-48095. I'll let you know when a fix is available.


0 Kudos
Barbara_P_Intel
Employee
747 Views

@Harald1, no more faulty error messages with ifx or ifort with the releases that were published this week. Please check them out!


0 Kudos
Harald1
New Contributor II
735 Views

Wow, the ICE is gone, and I get a correct result at runtime....

Thanks!

 

0 Kudos
Reply