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

Array bounds checking with Intel compiler: false positive

Harald1
New Contributor II
829 Views

The Intel compiler appears to be somewhat special with array bounds checking. When array expressions (like slices) are involved, -check bounds does not trigger. The suggested "correct" version is -check shape, which however has annoying false positives.

Example:

subroutine test (j,js,si)
implicit none
integer :: js(3,2), j(10,2), si(1,3)
js(:,:) = j(si(1,:),:)
js(1:3,1:2) = j(si(1,1:3),1:2)
end subroutine test

% ifort -V -check shape -c ifort-shape.f90
Intel(R) Fortran Intel(R) 64 Compiler Classic for applications running on Intel(R) 64, Version 2021.1 Build 20201112_000000
Copyright (C) 1985-2020 Intel Corporation. All rights reserved.

Intel(R) Fortran 2021.1-2085
ifort-shape.f90(4): error #5581: Shape mismatch: The extent of dimension 1 of array JS is 3 and the corresponding extent of array J is 1
js(:,:) = j(si(1,:),:)
----------------^
ifort-shape.f90(5): error #5581: Shape mismatch: The extent of dimension 1 of array JS is 3 and the corresponding extent of array J is 1
js(1:3,1:2) = j(si(1,1:3),1:2)
----------------^
compilation aborted for ifort-shape.f90 (code 1)


I hope this can be fixed some day...

Harald

0 Kudos
1 Solution
Devorah_H_Intel
Moderator
768 Views
"I hope this can be fixed some day..."

This has been fixed already. Be on the lookout for the upcoming 2021.2 ifort.

View solution in original post

0 Kudos
3 Replies
Devorah_H_Intel
Moderator
769 Views
"I hope this can be fixed some day..."

This has been fixed already. Be on the lookout for the upcoming 2021.2 ifort.
0 Kudos
Harald1
New Contributor II
694 Views
0 Kudos
Harald1
New Contributor II
673 Views

Indeed it is fixed in ifort 2021.2.0.  (The -check options seem to be not yet implemented in ifx).

Thanks,

Harald

0 Kudos
Reply