public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "burnus at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/41227] COMMON block, BIND(C) and LTO interoperability issues
Date: Mon, 14 Jul 2014 13:33:00 -0000	[thread overview]
Message-ID: <bug-41227-4-RGz9JDZ5gw@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-41227-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #22 from Tobias Burnus <burnus at gcc dot gnu.org> ---
(In reply to rguenther@suse.de from comment #19)
> > Well, Bill Long of Cray seems to agree with my interpretation, cf.
> > http://mailman.j3-fortran.org/pipermail/j3/2010-February/003358.html
> 
> But that answer suggests we get it wrong (currenty interoperating
> with the C struct { int i; } works and with the plain decl it
> doesn't).  The answer specifically doesn't say that only (1)
> is valid.

As I stumbled over it again (and missed what I wrote 5 years ago in comment 0):
One also needs to distinguish between common blocks with and without BIND(C). 


The Fortran standard only defines interoperability with C with Fortran 2003's C
binding ("BIND(C)"). Thus, "external int i" interoperates with
  use iso_fortran_env, only: c_int
  integer(c_int) :: j
  common /i/ j
  bind(C) :: /i/
and for this construct, "struct {int i}" does not have to interoperate with it
according to the standard. If the front-end produces the wrong code in this
case, one can simply fix it. Seems as if we have to do this, including the
output DWARF.

[By the way, I assume that there is essentially no code out there, which uses
BIND(C) with COMMON: Either it is pre-Fortran-2003 code - or it uses modules
where one avoids all those issues with COMMON and either has "integer, bind(C)
:: i" or "type(t), bind(C) :: i" and no ambiguity.]


The other case is legacy code: There, programs can make the wildest assumptions
what C code should interoperable with Fortran. See also T.S.'s comment 20.
Seems as if a simple "struct" was the most common assumption - with a nonstruct
being effectively interoperable with a one-variable struct; hence, also the
latter seems to be used.


  parent reply	other threads:[~2014-07-14 13:33 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <bug-41227-4@http.gcc.gnu.org/bugzilla/>
2012-01-05 13:38 ` rguenth at gcc dot gnu.org
2014-06-08 16:53 ` fxcoudert at gcc dot gnu.org
2014-06-10 13:06 ` rguenth at gcc dot gnu.org
2014-07-14 10:21 ` fxcoudert at gcc dot gnu.org
2014-07-14 10:36 ` rguenther at suse dot de
2014-07-14 10:45 ` fxcoudert at gcc dot gnu.org
2014-07-14 11:09 ` rguenth at gcc dot gnu.org
2014-07-14 11:20 ` fxcoudert at gcc dot gnu.org
2014-07-14 11:36 ` burnus at gcc dot gnu.org
2014-07-14 11:46 ` rguenther at suse dot de
2014-07-14 12:05 ` tobi at gcc dot gnu.org
2014-07-14 13:33 ` burnus at gcc dot gnu.org [this message]
2015-05-27 23:55 ` hubicka at gcc dot gnu.org
2009-09-02 14:26 [Bug fortran/41227] New: " burnus at gcc dot gnu dot org
2009-09-14 21:05 ` [Bug fortran/41227] " burnus at gcc dot gnu dot org
2009-09-28 19:59 ` tobi at gcc dot gnu dot org
2010-01-29 17:46 ` burnus at gcc dot gnu dot org
2010-02-02 10:29 ` burnus at gcc dot gnu dot org
2010-02-11 16:29 ` burnus at gcc dot gnu dot org
2010-02-23  9:08 ` burnus at gcc dot gnu dot org
2010-02-23  9:33 ` rguenther at suse dot de
2010-06-03 13:49 ` rguenth 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=bug-41227-4-RGz9JDZ5gw@http.gcc.gnu.org/bugzilla/ \
    --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).