Curious result in a simple program

program test_advdiff
    implicit none
    integer :: cout(3)
    cout=[0,1,1]
    associate( ccentre  => cout(2:3) , &
               cleft    => cout(1:2)  &
            )
               ![1,1] + [0,1] - [1,1]
        ccentre=ccentre+(cleft-ccentre)
        ! [1,0]
        write(*,*)ccentre
    end associate
end program test_advdiff

I simplify the code, And I think it is the bug for gfortran and ifort. nvfortran shows the right result.

> nvfortran
    0 1
> gfortran
    0 0
> ifort 
    0 0

and if change it as cleft => (cout(1:2)),the result is right.

1 Like