public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/51639] New: Nested type pointer null initialisation fails
@ 2011-12-20 16:28 jonathan.hogg at stfc dot ac.uk
  2011-12-20 16:45 ` [Bug fortran/51639] " dominiq at lps dot ens.fr
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: jonathan.hogg at stfc dot ac.uk @ 2011-12-20 16:28 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 51639
           Summary: Nested type pointer null initialisation fails
    Classification: Unclassified
           Product: gcc
           Version: 4.6.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: jonathan.hogg@stfc.ac.uk


The following code appears to produce a regression in 4.6:

program main
   implicit none

   type type1
      integer, dimension(:), allocatable :: member
   end type type1

   type type2
      type(type1), pointer :: t1ptr=>null()
   end type type2

   call test
contains

subroutine test
   type(type2) :: t2

   print *, "associated(t2%t1ptr) = ", associated(t2%t1ptr)

end subroutine test

end program

Produces the output
  associated(t2%t1ptr) =  T

but should produce the output
  associated(t2%t1ptr) =  F

Further valgrind shows that access is to an uninitialised pointer.

The code works as expected under 4.4.6 and 4.5.4.

To provoke the error it seems that the associated() check must occur within a
subroutine, and that type1 must have an allocatable component.

Thanks,

Jonathan.


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-12-20 17:44 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-12-20 16:28 [Bug fortran/51639] New: Nested type pointer null initialisation fails jonathan.hogg at stfc dot ac.uk
2011-12-20 16:45 ` [Bug fortran/51639] " dominiq at lps dot ens.fr
2011-12-20 16:56 ` [Bug fortran/51639] [4.6 Regression] " burnus at gcc dot gnu.org
2011-12-20 17:21 ` dominiq at lps dot ens.fr
2011-12-20 17:45 ` burnus at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).