public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "burnus at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/36058] Not allowing pointers to derived types in COMMON
Date: Sun, 27 Apr 2008 08:01:00 -0000	[thread overview]
Message-ID: <20080427080103.10479.qmail@sourceware.org> (raw)
In-Reply-To: <bug-36058-15045@http.gcc.gnu.org/bugzilla/>



------- Comment #1 from burnus at gcc dot gnu dot org  2008-04-27 08:01 -------
gfortran's rejection is in line with g95, NAG f95, ifort, openf95, sunf95 and
ifort.

I think gfortran is right and the sequence (or bind(C)) attribute is needed.

The reason is the same as for the following program:

  type my_t
    integer :: x, y, z
  end type my_t
  type(my_t) :: tt
  call foo(tt)
contains
subroutine foo(t)
  type foo_t
    integer :: x, y, z
  end type foo_t
  type(foo_t) :: t
end subroutine
end

foo_t and my_t are different, incompatible types without SEQUENCE. From that
point of view, it makes sense to reject your example.

Additionally, I think the following also applies to pointers. ("my_wwsptr" is
of a derived type [albeit with pointer attribute].)

"C589 (R558) If a common-block-object is of a derived type, it shall be a
sequence type (4.5.1) or a type with the BIND attribute and it shall have no
default initialization."

 * * *

If one now adds "SEQUENCE", gfortran rejects it as there is a default
initialization; in principle this it can be allowed as the default
initialization does not happen for pointers to derived types (only for its
targets). However, I believe that C589 also applies in this case.

The such modified program is rejected by NAG f95, sunf95, openf95, g95 and
gfortran, but ifort accepts the program.

 * * *

In conclustion, I think both error messages of gfortran are correct.


-- 


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


  reply	other threads:[~2008-04-27  8:01 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-27  4:25 [Bug fortran/36058] New: " w6ws at earthlink dot net
2008-04-27  8:01 ` burnus at gcc dot gnu dot org [this message]
2008-04-27 13:24 ` [Bug fortran/36058] " w6ws at earthlink dot net
2008-04-27 15:31 ` burnus at gcc dot gnu dot org
2008-04-29  5:22 ` burnus at gcc dot gnu dot org

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=20080427080103.10479.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).