equivalence croakage

Hans Horn hannes@2horns.com
Mon Nov 2 03:39:00 GMT 2009


Steve Kargl wrote:
> On Sun, Nov 01, 2009 at 11:53:58AM -0800, Hans Horn wrote:
>   
>> Folks,
>>
>> just trying to make the switch from g77 to gfortran (and from gcc3 to gcc4).
>> When compiling some legacy f77 code that uses f77 equivalence 
>> statements, I get barfed at with the following (32bit environment):
>>
>> <During initialization>
>>
>> Error: Overlapping unequal initializers in EQUIVALENCE at (1)
>>
>> Doesn't tell at all where the shit is happening.
>>
>> This code happens to compile with various f77 compilers (aix xlf, g77).
>>
>> I collected all the equivalence statements from the offending f77 source 
>> (all more or less variations of the same theme):
>>
>>       subroutine dud
>>       IMPLICIT NONE
>>       Character cDummy(8)/8*' '/, CSTORE(8)/8*' '/, CSTORE1(8)/8*' '/
>>       Integer   iDummy(2), ISTORE(2), ISTORE1(2)
>>       Real*8    rDummy(1), XSTORE
>>
>>       Equivalence(CSTORE(1),XSTORE,ISTORE)
>>       Equivalence(CSTORE1(1),ISTORE1)
>>       Equivalence(cDummy(1), iDummy(1), rDummy(1))
>>
>>       end
>>
>> this just happens to compile w/o a problem.
>>
>> Am I being kicked by a gfortran bug?
>>
>>     
>
> Please show the complete error message.
> Please show the actual code causing the problem.
> Please report the version of gfortran that you are using.
> Please report the options that you used.
>
> I doubt that it's a bug in gfortran.  I suspect it's a
> bug in your code because using equivalence correctly is
> actually more difficult than it may appear.
>
>   

Steve,

I was using gfortran v4.5 and this WAS the entire error message!

The legacy f77 code I was trying to compile was written in the early 90s.
I just fsplit the whole source file and compiled the bits.
Here's the offending subroutine:
ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc 

     Subroutine RestoreR8Run(IPASS,ibtoi,ibtor,nbyte,NSTORE,
    &                        XOUT,CXIN,TP9MN,TMN)
     Implicit NONE
     Integer IPASS,ibtoi(4),ibtor(8),nbyte,NSTORE,IBC,I,ISTORE/0/
     Real*8  XOUT(NSTORE), TP9MN,TMN,            XSTORE
     Character CXIN(nbyte*NSTORE),     CSTORE(8)/8*' '/
     EQUIVALENCE                      (CSTORE(1),XSTORE,ISTORE)

     IBC = 1
     if (nbyte.le.4) then
       DO I = 1, NSTORE
         call RestoreNByte(ISTORE,ibtoi,nbyte,CXIN(IBC),.false.)
         IF (IPASS .EQ. 1) then
           XOUT(I) = XOUT(I) + ISTORE * TP9MN       ! ISTORE and XSTORE 
are equivalenced
         else
           XOUT(I) = ISTORE * TMN
         endif
         IBC = IBC + nbyte
       enddo
     else
       DO I = 1, NSTORE
         CSTORE(ibtor(1)) = CXIN(IBC    )
         CSTORE(ibtor(2)) = CXIN(IBC + 1)
         CSTORE(ibtor(3)) = CXIN(IBC + 2)
         CSTORE(ibtor(4)) = CXIN(IBC + 3)
         CSTORE(ibtor(5)) = CXIN(IBC + 4)
         CSTORE(ibtor(6)) = CXIN(IBC + 5)
         CSTORE(ibtor(7)) = CXIN(IBC + 6)
         CSTORE(ibtor(8)) = CXIN(IBC + 7)
         XOUT(I) = XOUT(I) + XSTORE * TP9MN ! XSTORE and CSTORE are 
equivalenced
         IBC = IBC + 8
       enddo
     endif

     end
ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc 



commandline used:
gfc -c -Wuninitialized -Wunused-label -fno-underscoring -fno-f2c 
-ffixed-line-length-132  -g -gstabs -O  -march=pentium4 -pipe -x 
f77-cpp-input

When I remove the initialization of ISTORE/0/, it compiles - surprise.

Would be nice to get an error message that tells what's wrong.

H



More information about the Fortran mailing list