Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Array bounds checking with Intel compiler

350 views
Skip to first unread message

Harald Anlauf

unread,
Mar 18, 2021, 5:53:17 PM3/18/21
to
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

Beliavsky

unread,
Mar 19, 2021, 9:56:17 AM3/19/21
to
I agree it's a problem. Have you filed a bug report with Intel or reported it on the Intel Fortran forum?

gah4

unread,
Mar 21, 2021, 3:25:39 PM3/21/21
to
Does it depend on optimization level?

It seems that it is something that optimizations might get wrong.

The easy way is to expand the whole thing using loops, which should be easy to get right.
It is interesting that it discovers it at compile time.

Harald Anlauf

unread,
Mar 30, 2021, 4:39:55 PM3/30/21
to
The issue seems resolved with the: latest release:

Intel(R) Fortran Intel(R) 64 Compiler Classic for applications running on Intel(R) 64, Version 2021.2.0 Build 20210228_000000

gah4

unread,
Mar 30, 2021, 5:25:29 PM3/30/21
to
On Tuesday, March 30, 2021 at 1:39:55 PM UTC-7, Harald Anlauf wrote:
> The issue seems resolved with the: latest release:
>
> Intel(R) Fortran Intel(R) 64 Compiler Classic for applications running on Intel(R) 64, Version 2021.2.0 Build 20210228_000000

Just wondering, did you actually check which bounds the array was really using?

I presume that LBOUND and UBOUND agree with the actual array, but maybe not.

In the case of dummy arguments, LBOUND and UBOUND should give bounds that
agree with the array in the subroutine, such that it always works if you use them.

As well as I remember assumed shape lose them, ALLOCATABLE and POINTER
keep them, but I might have forgotten all the special cases.
0 new messages