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

Array assignment bug with -check shape

Ferdinand_T_
New Contributor II
277 Views

Hello,

I encountered a nasty silent runtime bug with the -check all (or, specifically, the -check shape) option in ifort 19.0.3.

Example:

program test
    integer, allocatable :: A(:,:)

    allocate(A(1,2))
    A(1,:) = [1,2]

    A = A([1],:)

    print *, A
end program 

Compile: ifort test.f90 -check all
Output:            1       32765

Generally, assignment from a multidimensional allocatable array variable to itself, using vector-subscripts on the RHS in the leading dimension (e.g. permuting rows of a matrix), results in corrupted array elements beyond the first column. No error or warning is given. Disabling automatic reallocation with -nostandard-realloc-lhs cures the problem.

Hopefully this post spares others lengthy debugging sessions.

Best regards,
Ferdinand

PS: Tested on Ubuntu 18.04.3 LTS and Red Hat Enterprise Linux Server release 7.7

 

0 Kudos
1 Reply
Ferdinand_T_
New Contributor II
277 Views

I just noted that this problem has been reported before: https://software.intel.com/en-us/forums/intel-fortran-compiler/topic/831548, this didn't come up with my forum search earlier.

0 Kudos
Reply