[Patch, gfortran] common blocks getting mangled in nested modules

Richard E Maine Richard.Maine@nasa.gov
Fri Aug 19 15:03:00 GMT 2005


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



More information about the Gcc-patches mailing list