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

Incorrect minloc/maxloc results with ifx 2024.0

NCarlson
New Contributor I
4,102 Views

The minloc/maxloc intrinsics return the incorrect result for 0-sized arrays with ifx 2024.0.  Here's an example program.  Note that the classic ifort compiler doesn't suffer from this error.

real :: a(0), b(2,0), c(3)
logical :: mask(3)
integer :: nfail

nfail = 0

! min/maxloc should return 0 for 0-sized arrays
if (maxloc(a,dim=1) /= 0) nfail = nfail + 1
if (minloc(a,dim=1) /= 0) nfail = nfail + 1

if (any(minloc(b) /= [0,0])) nfail = nfail + 1
if (any(maxloc(b) /= [0,0])) nfail = nfail + 1

! min/maxloc should return 0 when all mask values are false
c = [1.0, 2.0, 3.0]
mask = .false.
if (maxloc(c,dim=1,mask=mask) /= 0) nfail = nfail + 1
if (minloc(c,dim=1,mask=mask) /= 0) nfail = nfail + 1

if (nfail > 0) then
  print *, 'failed', nfail, 'tests'
else
  print *, 'passed all tests'
end if

end
0 Kudos
1 Solution
hakostra1
New Contributor II
4,074 Views

I searched around and found this old thread on the topic:

https://community.intel.com/t5/Intel-Fortran-Compiler/Change-in-result-of-MINLOC-MAXLOC-functions-when-all-elements-of/m-p/1125542

I tried your example and it works with '-standard-semantics' flag enabled... I do find it strange that such a flag is needed, though. The default behavior should be to follow the standard, then those that need another behavior should set the appropriate flags... Even just '-stand f18' did not help..

View solution in original post

22 Replies
Barbara_P_Intel
Employee
416 Views

ifort was able to detect when an object was created with -ipo.

With ifx, -ipo is translated to -flto, LTO=Link Time Optimization. See an example of using it with ifx.

 

 

0 Kudos
Barbara_P_Intel
Employee
402 Views

The remedy is to compile all routines involved in a module name mangling with -assume std_mod_proc_name.

The link thing is a red herring, my fault.



0 Kudos
Reply