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

ifort bug on deallocate

Alfredo_Buttari
Beginner
609 Views
Hello,
I found a bug in the ifort compiler. The deallocate statements in the code below return with a 173 error:
[fortran]program test_bug

  implicit none

  integer, pointer :: irn(:), jcn(:)
  integer, pointer :: tmp(:)
  integer :: error

  allocate(irn(10))
  allocate(jcn(10))

  tmp => irn(:)
  irn => jcn(:)
  jcn => tmp(:)
  nullify(tmp)

  deallocate(irn, stat=error)
  write(*,*)error
  deallocate(jcn, stat=error)
  write(*,*)error

  stop

end program test_bug
[/fortran]
I found the same issue in ifort V11.0 and V11.1 on the intel64 architecture. Didn't have any chance to test it on ia32. Is this bug known and/or already fixed?
best regards
alfredo
PS
I'm not sure whether this is correct way of reporting bugs but I couldn't find any other way. Is there any "official" mean to report bugs?
0 Kudos
4 Replies
TimP
Honored Contributor III
609 Views
....
deallocate(irn, stat=error,errmsg=error_message)
write(*,*)error,trim(error_message)
....
$ ./ab
173
A pointer passed to DEALLOCATE points to an array that cannot be deallocated
173
A pointer passed to DEALLOCATE points to an array that cannot be deallocated

I guess your point is you would like an option for compile-time error diagnostics? I suppose the section of an allocatable array (even if it copies the entire array) is distinct from the original allocated array and is not deallocatable. I didn't quickly find an expert discussion of your usage.
Evidently, with change to textbook syntax:
tmp => irn
irn => jcn
jcn => tmp
the behavior also changes to textbook style.

If you didn't set up a support account when you installed ifort, you can register your serial number at https://registrationcenter.intel.com and use the account at premier.intel.com to file your bug or feature request.
0 Kudos
Alfredo_Buttari
Beginner
609 Views
Tim,
I now realize that my code tries to deallocate a section of an array (even if the section corresponds to the whole array). I got fooled by the fact that the same code works with gfortran. I slightly modified the title of the thread and removed the word "bug".
Best regards
alfredo
0 Kudos
mecej4
Honored Contributor III
609 Views
Here are the sections of the standard that rule out using an array section as target instead of an array in this context:

Section 7.4.2:

8 R735 pointer-assignment-stmt is data-pointer-object [ (bounds-spec-list) ] => data-target

28 R739 data-target is variable
29 or expr

30 C723 (R739) A variable shall have either the TARGET or POINTER attribute, and shall not be an
31 array section with a vector subscript.
0 Kudos
Alfredo_Buttari
Beginner
609 Views
Mecej,
thanks your your very useful explanation.
Regards
alfredo
0 Kudos
Reply