Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!uunet!mcsun!ukc!edcastle!dcl-cs!gdt!gdr!exspes From: exspes@gdr.bath.ac.uk (P E Smee) Newsgroups: comp.lang.c,comp.sys.super Subject: Re: Type punning in C Message-ID: <1989Oct16.101817.3306@gdt.bath.ac.uk> Date: 16 Oct 89 10:18:17 GMT References: <475@idacrd.UUCP> <1989Oct10.185851.6490@agate.berkeley.edu> <1989Oct11.091619.18336@gdt.bath.ac.uk> <126279@sun.Eng.Sun.COM> <1989Oct16.092936.142@gdt.bath.ac.uk> Reply-To: exspes@gdr.bath.ac.uk (P E Smee) Organization: University of Bristol c/o University of Bath Lines: 30 In article <1989Oct16.092936.142@gdt.bath.ac.uk> exspes@gdr.bath.ac.uk (P E Smee) writes: >In article <126279@sun.Eng.Sun.COM> khb@sun.UUCP (Keith Bierman - SPD Advanced Languages) writes: >>In article <1989Oct11.091619.18336@gdt.bath.ac.uk> exspes@gdr.bath.ac.uk (P E Smee) writes: >> >> >>>Problem is, the Fortran standard *also* says that if your program tries >>>to take the value of the variable using a different type than the type you >>>used when you last stored into it, your program is invalid. >> >>My quick peek into the document (pages 8-3 and 17-1..4ish) doesn't >>make this obvious to me. Could you please quote chapter and verse ? >> In the previous posting, I quoted chapter and verse from the 77 FORTRAN standard. The 66 standard is even stricter. EQUIVALENCE causes things to become associated (full stop -- no fudging about partial or total association) and says in 10.2.3.1 (5) [Variables and array elements become undefined as follows:] When an associated entry of different type becomes defined. So, I'd say the 66 standard prohibits it completely, while the 77 standard allows it in some cases (but only when the variables are not (loosely speaking) of the same size). The one interesting case which is explicitly valid in 77 appears to be EQUIVALENCE of a REAL array of dimension 2 with an COMPLEX variable, in which case REAL(1) would be the real part of the COMPLEX and REAL(2) the imaginary part. -- Paul Smee | JANET: Smee@uk.ac.bristol Computer Centre | BITNET: Smee%uk.ac.bristol@ukacrl.bitnet University of Bristol | Internet: Smee%uk.ac.bristol@nsfnet-relay.ac.uk (Phone: +44 272 303132) | UUCP: ...!mcvax!ukc!gdr.bath.ac.uk!exspes