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

maxloc and minloc return the wrong values for 0-sized arrays

NCarlson
New Contributor I
505 Views

According to the standard, all elements of the result  of the intrinsic functions minloc and maxloc should be 0 if their array argument is 0-sized.  But with Intel Fortran the elements are 1 instead: 

integer, allocatable :: a(:), b(:,:)
allocate(a(0), b(2,0))
print *, maxloc(a)
print *, maxloc(b)
end

This should print

0
0 0

But instead I get

1
1 1

 This is with the latest 2021.5.0 version and goes back to at least 18.0

Labels (1)
0 Kudos
1 Solution
Steve_Lionel
Honored Contributor III
502 Views

/standard-semantics is your friend - sets /assume:noold_maxminloc.

View solution in original post

4 Replies
Steve_Lionel
Honored Contributor III
503 Views

/standard-semantics is your friend - sets /assume:noold_maxminloc.

NCarlson
New Contributor I
499 Views

Argh...  I don't know why that didn't occur to me (it's resolved "problems" in the past).  Thanks!  I need a config file so that that flag is always automatically included.  Is such a thing possible?

0 Kudos
Steve_Lionel
Honored Contributor III
495 Views

I'll comment that maxloc/minloc initially did not define the result in this case. It was clarified in F2008, I think.

0 Kudos
Reply