DOCERR: Code in Manual Incorrect: COMMON and EQUIVALENCE

Last reviewed: July 18, 1995
Article ID: Q87886
The information in this article applies to:
  • Microsoft FORTRAN for MS-DOS, versions 5.0 and 5.1
  • Microsoft FORTRAN for OS/2, versions 5.0 and 5.1

SYMPTOMS

When compiled with Microsoft FORTRAN version 5.0 or 5.1 under MS-DOS or OS/2, the sample program given on page 132 of the "Microsoft FORTRAN Advanced Topics" version 5.0 manual and page 105 of the "Microsoft FORTRAN Advanced Topics" version 5.1 manual generates the following error:

   error F2318: A, B : EQUIVALENCE: in different common blocks

CAUSE

The version 5.1 FORTRAN "Reference Manual" states:

   An EQUIVALENCE statement cannot share memory between two different
   common blocks or between elements of the same common block.

The error F2318 is generated in this case because the sample code attempts to EQUIVALENCE the arrays A and B that belong to two different COMMON blocks.

RESOLUTION

To avoid this error, compile the code after removing either A or B or both the arrays from COMMON blocks.

MORE INFORMATION

The following code, which is incorrect, is from the "Microsoft FORTRAN Advanced Topics" manual:

      integer a(10,20), b(20,30)
      common /cba/a, /cbb/b
      equivalence (a(10,20), b(1,1))
      end

The following code illustrates the correct usage of EQUIVALENCE statement and common blocks:

      integer a(10,20), b(20,30)
      common /cba/ a
      equivalence (a(10,20), b(1,1))
      end


Additional reference words: 5.00 5.10
KBCategory: kbprg kbdocerr kbcode
KBSubcategory: FORTLngIss


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: July 18, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.