Возможная ошибка в ifort 2015

Я думаю, что наблюдаю ошибку в 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

Второй результат — хороший, и я не вижу причин для разницы.

файл 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

Как видишь, я ничего не выдумываю. Я пытался максимально сократить код. Пробовал на трех компьютерах с тремя версиями ifort (15.0.0 20140723, 15.0.2 20150121 и 14.0.0 20130728). Я всегда вижу одно и то же.

Я не вижу этого с gfortran (4.8.2 или 5.1.0)

Он кажется большим, и я уверен, что совершаю ошибку, но я его не вижу.

Любая помощь будет оценена

редактировать: я под Linux (ubuntu и archlinux)


person pums974    schedule 05.05.2015    source источник
comment
Мой друг только что попробовал это на другом компьютере (четвертый так долго) и увидел это. Вы скомпилировали с -O1 -g ? оба важны.   -  person pums974    schedule 05.05.2015
comment
Воспроизводится с -O1 -g, но исчезает при более высоких уровнях оптимизации. ифорт 14.0.1   -  person casey    schedule 05.05.2015
comment
По-видимому, нет ошибки в Windows с ifort 15.0.2.179 build 20150121 (однако, возможно, я не использую правильный параметр, так как нет параметра -g, поэтому я заменил его на /debug)   -  person    schedule 06.05.2015
comment
Действительно, никаких проблем с окнами, по-видимому.   -  person pums974    schedule 06.05.2015


Ответы (1)


Вы правы - это ошибка в ifort. Я отправил это разработчикам.

person Steve Lionel    schedule 05.05.2015
comment
Спасибо, я с нетерпением жду быстрого исправления, потому что, хотя ошибку очень легко обойти в тестовом примере, в моем реальном коде я еще не нашел обходного пути. - person pums974; 05.05.2015
comment
Для тех, кто заинтересован, есть продолжение здесь software.intel.com/en -нас/форумы/тема/557311 - person pums974; 06.05.2015