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

Simplification of FINDLOC with array of size 0 fails

Harald1
New Contributor II
729 Views

The following code is rejected by ifort 2021.6.0:

program p
! integer, parameter :: ii(1) = findloc ([integer::1],1) ! works
  integer, parameter :: ii(1) = findloc ([integer:: ],1) ! fails
  print *, ii
  print *, findloc ([integer::],1) ! accepted
end

This gives:

% ifort ifort-findloc.f90
ifort-findloc.f90(3): error #6821: A scalar constant is required in this context.
  integer, parameter :: ii(1) = findloc ([integer:: ],1) ! fails
--------------------------------^
compilation aborted for ifort-findloc.f90 (code 1)

It shouldn't be too hard to do the simplification...

 

0 Kudos
1 Solution
Barbara_P_Intel
Moderator
634 Views

I filed a bug report on this erroneous error message, CMPLRIL0-34931.



View solution in original post

0 Kudos
4 Replies
Mark_Lewy
Valued Contributor I
670 Views

I'd argue that this is a compiler bug as

findloc ([integer:: ],1)

looks like a legitimate constant expression (according to MFE 8.4).

I note also that gfortran --warn-all (MSYS2 10.2.0) compiles this without any warnings and produces the desired output.

0 Kudos
Barbara_P_Intel
Moderator
635 Views

I filed a bug report on this erroneous error message, CMPLRIL0-34931.



0 Kudos
Barbara_P_Intel
Moderator
429 Views

This FINDLOC() issue is resolved in the latest Fortran compilers that were released in December. Give it a try!



0 Kudos
Harald1
New Contributor II
416 Views

Yes, it is fixed in the latest version.  Thanks!

 

0 Kudos
Reply