pums974
pums974

Reputation: 135

Possible bug in ifort 2015

I think i'm observing a bug in ifort 2015.

$> ifort test.f90 -O1 -g  && ./a.out
6 0 0 0 0 0 0
1 0
$> ifort test.f90 -O0 -g  && ./a.out
6 0 0 0 0 0 0
6 0 0 0 0 0 0

The second result is the good one, and I see no reason for the difference.

file test.f90 :

module useless_module
! this module is useless
! remove it and the bug disappear
  implicit none
! those variables are useless
! they will never be touched
! remove one of them and the bug disappear
! rename one of them and the bug disappear
  integer,allocatable,dimension(:) :: num_dr , &
                                      num_cf , &
                                      num_cfi, &
                                      num_num, &
                                      num_typ
end module useless_module

program test_program
  implicit none
! those variables are useless
! they will never be touched
! remove one of them and the bug disappear
  integer,allocatable,dimension(:) :: a1, b1, c1, d1, &
                                      e1, g1, f1, h1, &
                                      i1, j1, k1

  call routine_1(a1,b1,c1,d1,e1,f1,g1,h1,i1,j1,k1)
contains

  subroutine routine_1(a3,b3,c3,d3,e3,f3,num_cf,num_dr, &
                       num_typ,num_num,num_cfi)
    implicit none
! those arguments are useless
! they will never be touched
! remove one of them and the bug disappear
      integer,allocatable,dimension(:)     :: a3,b3,c3,d3,e3,f3
! those arguments are useless
! they will never be touched
! remove one of them and the bug disappear
! rename one of them and the bug disappear
      integer,allocatable,dimension(:)     :: num_dr , &
                                              num_cf , &
                                              num_cfi, &
                                              num_num, &
                                              num_typ
! this variable is useless
! it will never be touched
! remove it and the bug disappear
      integer,allocatable,dimension(:)     :: g3
! those variables are actualy used !
      integer,allocatable,dimension(:,:,:) :: h3,i3,j3

      allocate(h3(1,1,1),i3(1,1,1),j3(1,1,1))

      call routine_2(g3,i3,j3)

! here, normaly, size(i3)=6 and i3= 0 0 0 0 0 0
! But that is not what is printed : BUG ?
! printing size(i3) AND i3 is mandatory to make the bug happen
      write(*,'(7i2)') size(i3),i3
      deallocate(h3,i3,j3)
  end subroutine routine_1

  subroutine routine_2(a2,b2,c2)
    use useless_module
    implicit none
      integer,allocatable,dimension(:)     :: a2,d2,e2,f2,g2
      integer,allocatable,dimension(:,:,:) :: b2, c2
      integer                              :: j2

! j2 have to be be a variable
      j2=1
! allocate and deallocate some array
! not doing that will make the bug desappear
      allocate  (d2(j2),e2(1),f2(1),g2(1))
      deallocate(d2   ,e2    ,f2   ,g2)

      call reallocate(  c2,3,2,1)
      call reallocate(  b2,3,2,1) ;   b2=0

! here, we have size(b2)=6 and b2= 0 0 0 0 0 0
! printing size(b2) AND b2 is mandatory to make the bug happen
      write(*,'(7i2)') size(b2),b2
  end subroutine routine_2

  subroutine reallocate(a4,b4,c4,d4)
    implicit none
    integer,allocatable,dimension(:,:,:) :: a4
    integer                              :: b4,c4,d4

    deallocate(a4) ; allocate(a4(b4,c4,d4))

  end subroutine reallocate

end program test_program

As you can see, I'm doing nothin fancy. I tried to reduce the code a much as i could I tried on three computer with three version of ifort (15.0.0 20140723, 15.0.2 20150121 and 14.0.0 20130728) I always see the same thing.

I don't see it with gfortran (4.8.2 or 5.1.0)

It seems big, and I'm sure I'm making a mistake, but I don't see it.

Any help will be appreciated

edit : I'm under linux (ubuntu and archlinux)

Upvotes: 3

Views: 169

Answers (1)

Steve Lionel
Steve Lionel

Reputation: 7277

You are correct - this is a bug in ifort. I have sent this on to the developers.

Upvotes: 3

Related Questions