From: dpb on
analyst41(a)hotmail.com wrote:
> On Jul 11, 10:58 am, dpb <n...(a)non.net> wrote:
>> analys...(a)hotmail.com wrote:
>>
>> ...
>>
>>> It was
>>> common /name1/var1,var2 everywhere except one sub-program where it was
>>> common /name1/var1,var2
>>> common /name1/var3,var4,var5
>>> And it compiles just fine. The compiler does warn in cases like
>> Yes, the second statement simply extends the named common NAME1 just as
>> if it had been written as
>>
>> common /name1/ var1,var2,var3,var4,var5
>>
>
> and that ought to generate a size mismatch warning from the compiler
> and for some reason it doesn't happen.

No, that's the point that it _isn't_ an error until there are two or
more program units one of which that doesn't match.

That can't be caught by the compiler unless it's doing diagnostics on
more than the single compilation unit (which, remember, is
program/function/subroutine in Fortran not file or other scoping unit.

That some compilers do look at more is an extension and
_a_very_good_thing_ (tm) but it isn't required.

Otherwise, the information wouldn't be available until linking and as
Gordon says, handling that is also compiler-dependent.

--
From: Phillip Helbig---undress to reply on
In article
<c0965900-6bfa-4fd6-8307-09da277d7ab4(a)s9g2000yqd.googlegroups.com>,
"analyst41(a)hotmail.com" <analyst41(a)hotmail.com> writes:

> I have been running code foreever that had
>
> common /name1/var1,var2
> common /name1/var3,var4,var5

> Why doesn't the compiler (Lahey) flag this as an error or at least as
> a warning?

Because the code is correct. This is called "extending a common block".
What would you do if you needed more than 19 lines to declare
everything? Without the possibility of extension in a separate
statement, you would be limited in the number of variables in the common
block.

From: robin on
"Gordon Sande" <Gordon.Sande(a)gmail.com> wrote in message news:2010071110570675249-GordonSande(a)gmailcom...
| On 2010-07-11 10:08:21 -0300, dpb <none(a)non.net> said:
|
| > analyst41(a)hotmail.com wrote:
| >> I have been running code foreever that had
| >>
| >> common /name1/var1,var2
| >> common /name1/var3,var4,var5
| >>
| >> in the same sub-program.
| >>
| >> The intent was, of course, to call the second common /name2/.
| >>
| >> I corrected it and the results are still the same, because
| >> var3,var4,var5 occur only in that sub-program (I haven't gotten round
| >> to doing whatever I was planning to do with var3-5.)
| >>
| >> Why doesn't the compiler (Lahey) flag this as an error or at least as
| >> a warning?
| >
| > Because it isn't???
| >
| > "Any common block name (or blank common) can appear more than once in
| > one or more COMMON statements in a program unit. The list following
| > each successive appearance of the same common block name is treated as
| > a continuation of the list for the block associated with that name. "
| >
| > Above from CVF documentation, not the Standard, but it is conforming
| > behavior if not the exact wording.
|
| Except all the various references to the common block named name1
| should be of the
| same size. Not enforcing this is a common extension.
|
Well, I wouldn't call it an "extension" but an undiagnosed bug.
It was picked up by some linkers.

It was difficult for the compiler to diagnose when procedures were separately compiled.