Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29423 ディスカッション

Array bounds checking with Intel compiler: false positive

Harald1
新規コントリビューター II
1,756件の閲覧回数

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 件の賞賛
1 解決策
Devorah_H_Intel
モデレーター
1,695件の閲覧回数
"I hope this can be fixed some day..."

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

元の投稿で解決策を見る

3 返答(返信)
Devorah_H_Intel
モデレーター
1,696件の閲覧回数
"I hope this can be fixed some day..."

This has been fixed already. Be on the lookout for the upcoming 2021.2 ifort.
Harald1
新規コントリビューター II
1,621件の閲覧回数
Harald1
新規コントリビューター II
1,600件の閲覧回数

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

Thanks,

Harald

返信