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

Array bounds checking with Intel compiler: false positive

Harald1
Novice
454 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
393 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

3 Replies
Devorah_H_Intel
Moderator
394 Views
"I hope this can be fixed some day..."

This has been fixed already. Be on the lookout for the upcoming 2021.2 ifort.
Harald1
Novice
319 Views
Harald1
Novice
298 Views

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

Thanks,

Harald

Reply