This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [Patch, gfortran] common blocks getting mangled in nested modules
- From: Richard E Maine <Richard dot Maine at nasa dot gov>
- To: Paul Thomas <paulthomas2 at wanadoo dot fr>
- Cc: "'fortran at gcc dot gnu dot org'" <fortran at gcc dot gnu dot org>, patch <gcc-patches at gcc dot gnu dot org>, Tobias dot Schlueter at Physik dot Uni-Muenchen dot DE
- Date: Fri, 19 Aug 2005 07:57:02 -0700
- Subject: Re: [Patch, gfortran] common blocks getting mangled in nested modules
- References: <1124396183.4304ec973d049@www.cip.physik.uni-muenchen.de> <43056D29.3020304@wanadoo.fr>
On Aug 18, 2005, at 10:24 PM, Paul Thomas wrote:
Tobi,
What if one uses different modules which contain the same common
block, will
they not interfere?
Yes, they are correctly determined to be ambiguous.
gfortran - Error: Name 'a' at (1) is an ambiguous reference to 'a'
from module 'm1'
This might not be to the point, but as an editor, I look carefully for
imprecision in wording. Sometimes it signals misunderstandings of the
material; other times not.
In particular, there is nothing at all wrong with USEing two different
modules that contain the "same" common block. The ambiguity referred to
relates only to names. There are multiple ways for the storage units of
a common block to have different names in this scenario. Most
trivially, there is USE with rename. Also, don't forget that variables
in the same common block can have different names in different
occurrences of the common block.
As long as the local names end up different, one way or another, in the
scoping unit that USEs both modules, then there is nothing wrong with
using different modules which contain the same common block. This needs
to work.
My apologies if this is off the point and is obvious to all. But I have
run into people who forget parts of it - particularly the bit about
different instances of a common having different variable names. And I
run into a lot of people (including several on J3) who keep forgetting
that USE accessibility relates only to names and not to the underlying
objects. It seems safer to belabor the point than to possibly let a
misunderstanding propagate.
--
Richard Maine | Good judgment comes from experience;
Richard.Maine@nasa.gov | experience comes from bad judgment.
| -- Mark Twain