Quantcast
Channel: Intel® Software - Intel® Fortran Compiler for Linux* and macOS*
Viewing all articles
Browse latest Browse all 2746

Compiler bug ? Passing explicit/assumed-shape dummy arrays

$
0
0

Hello,

I just get confused about ifort behavior.

Here is a minimal sample program causing me trouble :

program bug
implicit none
integer,parameter :: nb=1
integer,dimension(5,nb) :: array
integer :: n
    n=1
    do while (n<=size(array,1))
        call fill(2,array(n,:),n)
    end do
write(*,*) array
contains
    subroutine fill(nb,vec,n)
    integer,intent(in)::nb
    integer,dimension(nb),intent(out) :: vec
    integer,intent(inout) :: n
        vec=n
        n=n+1
    end subroutine fill
end program bug

output :

0 1 2 3 4

And with -check all at compilation i got : "Subscript #1 of the array ARRAY has value 6 which is greater than the upper bound of 5"

Howerer, if i change

 integer,dimension(nb),intent(out) :: vec
to an assumed-shape form :
 integer,dimension(:),intent(out) :: vec
the program behaves normally and the output is :
1 2 3 4 5
.

This bug (?) does not appear when using gfortran instead of ifort.

ifort version : 12.1.0 20111011

Regards,

Simon.


Viewing all articles
Browse latest Browse all 2746

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>