Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!mips!pacbell.com!ucsd!hub.ucsb.edu!appmag!curly.appmag.com!pa From: pa@curly.appmag.com (Pierre Asselin) Newsgroups: comp.lang.fortran Subject: Re: More on EQUIVALENCE (and CHARACTER) Summary: It's standard Message-ID: <720@curly.appmag.com> Date: 10 Jun 91 19:29:07 GMT References: <1991Jun1.171914.802@weyrich.UUCP> <1991Jun5.220805.4653@alchemy.chem.utoronto.ca> <1991Jun7.022834.898@weyrich.UUCP> <1991Jun7.144220.16691@alchemy.chem.utoronto.ca> <91159.121142FC138001@ysub.ysu.edu> Reply-To: pa@curly.appmag.com (Pierre Asselin) Distribution: na Organization: Applied Magnetics, Goleta, CA Lines: 38 In article <91159.121142FC138001@ysub.ysu.edu> FC138001@ysub.ysu.edu (Phil Munro) writes: >[...] > The above discussion raises questions for me. Will the following code >be portable? Might it cause problems on some compilers when trying to >pick off part of whole and overlay storage? I know in the case of the >VS compiler that character storage allows this sort of thing. > > character*14 whole > character*4 part > data whole /'part and so on'/ > equivalence (whole,part) > > Or, here is another simpler example which I have used: > > character*8 blank8 > character*4 blank > equivalence (blank8,blank) > data blank8 /' '/ This is a quote from X3.9-1978 (section 8.2.3): # In the example: # # CHARACTER A*4, B*4, C(2)*3 # EQUIVALENCE (A(C(1)), (B,C(2)) # # The association of A, B, and C can be graphically illustrated as: # # |01|02|03|04|05|06|07| # |-----A-----| # |-----B-----| # |--C(1)--|--C(2)--| I don't want to quote the whole section, but the example shows that your intuition is probably right. The equivalences do not hold beyond the declared bounds. Do not assume, say, that A(5:5) exists and is associated with B(2:2). --Pierre Asselin, R&D, Applied Magnetics Corp. I speak for me.