[Bug fortran/41227] COMMON block, BIND(C) and LTO interoperability issues

burnus at gcc dot gnu dot org gcc-bugzilla@gcc.gnu.org
Fri Jan 29 17:46:00 GMT 2010



------- Comment #3 from burnus at gcc dot gnu dot org  2010-01-29 17:45 -------
I have now asked at comp.lang.fortran:

http://groups.google.com/group/comp.lang.fortran/browse_thread/thread/c00efc5679b6a879

(In reply to comment #2)
> The way usually recommended is to use a struct for interoperability with
> Fortran common blocks, say http://support.microsoft.com/kb/51614

That matches - for multiple variables in the block - the Fortran 2003 standard.

> Unfortunately, the idiom "use a single variable common block, say common/x/y,
> access it via the name of the common block, followed by an underscore, say x_"
> is also common.  At least in my workplace it's the way everybody uses.

That matches what Fortran 2003 says about a single variable.

> In other words, we can't afford to break either way.

Well, as long as you do not use LTO it does not seem to matter. And if LTO you
have to decide for "struct" or against "struct". (And as a user, use BIND(C) -
either with COMMON or with TYPE - and you get a well-defined result.)

I am leaning towards using a "struct" only when there are multiple variables,
which makes BIND(C) and non-BIND(C) behave identical. If the overwhelming
opinion is differently, one can still add a "&& attr->is_bind_c".


-- 


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



More information about the Gcc-bugs mailing list