https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121435

kargls at comcast dot net changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kargls at comcast dot net

--- Comment #1 from kargls at comcast dot net ---
It appears that default initialization is not occurring for
the main program unit.  Here's a slightly modified and expanded
test.


  program foo

    integer, target :: v(5) = [1, 2, 3, 4, 5]

    type entry
      integer, pointer :: p(:) => v    ! default initialization
    end type entry

    type(entry) test
    type(entry), allocatable :: d

    ! This causes a segfault at runtime, because default
    ! initialization is not occurring in the main program
    ! unit.
    !
    ! if (any(v /= test%p)) stop 1
    ! print *, test%p

    call bar(test)

    block
      ! def. init. occurs in block construct
      type(entry) b
      if (any(v /= b%p)) stop 3
    end block

    ! def. init. occurs in allocation
    allocate(d)
    if (any(v /= d%p)) stop 4

    contains
      ! def. init. occurs for intent(out) dummy argument
      subroutine bar(a)
        type(entry), intent(out) :: a
        if (any(v /= a%p)) stop 2
      end subroutine bar
  end program foo

Reply via email to