public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/40167]  New: wrong initialization of local variable in a recursive subroutine
@ 2009-05-16  8:46 francois dot jacq at irsn dot fr
  2009-05-18  4:46 ` [Bug fortran/40167] " pault at gcc dot gnu dot org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: francois dot jacq at irsn dot fr @ 2009-05-16  8:46 UTC (permalink / raw)
  To: gcc-bugs

In the following program, env%n should be equal to zero when entering the
routine "titi" but one gets the output :

  10 0
   5 10

instead of

  10 0
   5 0

as if the local variable "env" was declared "save" within "titi". Notice that
the bug disappears if the allocatable array "a" is deleted in the definition of
"env_type" : so the presence of an allocatable element within a derived type
seems to be related to that bug.

MODULE m

  TYPE env_type
    INTEGER :: n=0
    INTEGER,ALLOCATABLE :: a(:)
  END TYPE

  CONTAINS

  RECURSIVE SUBROUTINE titi(n)

    INTERFACE
      RECURSIVE SUBROUTINE tata()
      END SUBROUTINE
    END INTERFACE

    TYPE(env_type) :: env
    WRITE(*,*) n,env%n
    env%n=n
    IF(n == 5) STOP
    CALL tata()

  END SUBROUTINE

END MODULE

RECURSIVE SUBROUTINE tata
  USE m
  CALL titi(5)
END SUBROUTINE

PROGRAM test
  USE m
  INTERFACE
    RECURSIVE SUBROUTINE tata()
    END SUBROUTINE
  END INTERFACE
  CALL titi(10)
END PROGRAM


-- 
           Summary: wrong initialization of local variable in a recursive
                    subroutine
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: francois dot jacq at irsn dot fr
  GCC host triplet: windows xp i386
GCC target triplet: gcc 4.3.0 20080305 (alpha-testing) mingw-20080502


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


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

end of thread, other threads:[~2009-05-18  8:51 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-05-16  8:46 [Bug fortran/40167] New: wrong initialization of local variable in a recursive subroutine francois dot jacq at irsn dot fr
2009-05-18  4:46 ` [Bug fortran/40167] " pault at gcc dot gnu dot org
2009-05-18  6:41 ` burnus at gcc dot gnu dot org
2009-05-18  7:44 ` francois dot jacq at irsn dot fr
2009-05-18  8:17 ` francois dot jacq at irsn dot fr
2009-05-18  8:51 ` burnus at gcc dot gnu dot 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).