[Bug fortran/55072] [4.6/4.7/4.8 Regression] Missing internal_pack leads to wrong code with derived type

janus at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Thu Dec 13 21:39:00 GMT 2012


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55072

janus at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2012-12-13
     Ever Confirmed|0                           |1

--- Comment #2 from janus at gcc dot gnu.org 2012-12-13 21:39:29 UTC ---
It seems I found yet another reincarnation of this bug (spotted in the wild,
unfortunately):


program GiBUU_neutrino_bug

  Type particle
    integer :: ID
  End Type

  type(particle), dimension(1:2,1:2) :: OutPart

  OutPart(1,:)%ID = 1
  OutPart(2,:)%ID = 2

  call s1(OutPart(1,:))

contains

  subroutine s1(j)
    type(particle) :: j(:)
    print *,j(:)%ID
    call s2(j)
  end subroutine

  subroutine s2(k)
    type(particle) :: k(1:2)
    print *,k(:)%ID
  end subroutine

end


It is expected to print
           1           1
           1           1
which it does with 4.3 and 4.4. As the test case in comment 0, it fails with
everything from 4.5 up to trunk, printing:
           1           1
           1           2
A workaround is to declare both 'i' and 'j' in the same way, as either (:) or
(1:2).



More information about the Gcc-bugs mailing list