public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "sven dot buijssen at math dot uni-dortmund dot de" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/34438] gfortran not compliant w.r.t default initialization of derived type component and implicit SAVE attribute
Date: Wed, 12 Dec 2007 15:04:00 -0000	[thread overview]
Message-ID: <20071212150410.8627.qmail@sourceware.org> (raw)
In-Reply-To: <bug-34438-11543@http.gcc.gnu.org/bugzilla/>



------- Comment #2 from sven dot buijssen at math dot uni-dortmund dot de  2007-12-12 15:04 -------
Having reread the Fortran 95 language spec I don't see why the initial testcase
violates the standard. But I managed to distill a testcase that does not need
recursive functions and still triggers the bug of 'foo' getting implicitly the
SAVE attribute:

--- cut here ---
module demo
  implicit none
  private
  type myint
    integer :: bar = 42
  end type myint
  public :: func
contains
  subroutine func(ivalue)
    integer, intent(in) :: ivalue
    type(myint) :: foo
    print *, foo%bar
    foo%bar = ivalue
  end subroutine func
end module demo

program main
  use demo
  implicit none
  call func(1)
  call func(2)
end program main
--- cut here ---

In case this piece of code still violates the standard, I would very much
appreciate a hint where and why exactly it does. (Sorry to waste your time.)

gfortran 4.[1-2].x gives:
$ gfortran -W -Wall -pedantic -std=f95 demo3.f90 && ./a.out
          42
           1
while one would expect two times '42' as do Intel Fortran 9.x/10.x, PGI 7.x,
Pathscale 3.x, recent g95 versions, Compaq Fortran X5.4A-1684 and Sun Fortran
95 8.3 2007/07/18.

Without the private/public statements gfortran 4.3.x exhibits the same
behaviour. The test case above, however, gives

    type(myint) :: foo
                     1
Error: Fortran 2003: PUBLIC variable 'foo' at (1) of PRIVATE derived type
'myint'

which seems unrelated to me and for which I probably should submit a new bug
report. I added this information here nonetheless as it might help to trace the
problem.


-- 


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


  parent reply	other threads:[~2007-12-12 15:04 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-12-11 23:14 [Bug fortran/34438] New: " sven dot buijssen at math dot uni-dortmund dot de
2007-12-11 23:23 ` [Bug fortran/34438] " kargl at gcc dot gnu dot org
2007-12-12  7:05 ` jv244 at cam dot ac dot uk
2007-12-12 15:04 ` sven dot buijssen at math dot uni-dortmund dot de [this message]
2007-12-12 16:12 ` jv244 at cam dot ac dot uk
2007-12-12 20:29 ` burnus at gcc dot gnu dot org
2007-12-14 12:53 ` pault at gcc dot gnu dot org
2007-12-14 15:14 ` burnus at gcc dot gnu dot org
2007-12-15  0:29 ` pault at gcc dot gnu dot org
2007-12-17 20:04 ` burnus at gcc dot gnu dot org
2007-12-21 21:21 ` pault at gcc dot gnu dot org
2007-12-26 14:25 ` tkoenig at gcc dot gnu dot org
2007-12-26 22:01 ` sven dot buijssen at math dot uni-dortmund dot de
2007-12-26 23:42 ` kargl at gcc dot gnu dot org
2007-12-28 10:54 ` sven dot buijssen at math dot uni-dortmund dot de

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20071212150410.8627.qmail@sourceware.org \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).