Type punning in C

Myron A. Calhoun mac at harris.cis.ksu.edu
Thu Oct 12 23:10:38 AEST 1989


In article <1654 at l.cc.purdue.edu> cik at l.cc.purdue.edu (Herman Rubin) writes:
>In article <1989Oct11.091619.18336 at gdt.bath.ac.uk>, exspes at gdr.bath.ac.uk (P E Smee) writes:
>> In article <1989Oct10.185851.6490 at agate.berkeley.edu> jerry at violet.berkeley.edu ( Jerry Berkman ) writes:
>< >Why not use equivalence?

 [several lines deleted]

>> Problem is, the Fortran standard *also* says that if your program tries...

 [several lines deleted]

>This is another example of those "gurus" who can not envision an intelligent
>user using the machine in an intelligent manner, and prevent that use.  I
>have deliberately used "type punning" on various machines, and I consider it
>an extremely useful tool.....

 [several lines deleted]

I agree wholeheartedly.  FORTRAN doesn't have PL/1's UNSPEC verb, yet
I have had occasion to want it.  And EQUIVALENCE provided it.
Calling a subroutine with "wrong" type parameters can also work:
   CALL NEWTYP (INTEGER,...)
       :::::
   SUBROUTINE NEWTYP (REAL,...)
--Myron
--
Myron A. Calhoun, PhD EE, W0PBV, (913) 532-6350 (work), 539-4448 (home).
INTERNET: mac at ksuvax1.cis.ksu.edu
BITNET:   mac at ksuvax1.bitnet
UUCP:  ...{rutgers, texbell}!ksuvax1!harry!mac



More information about the Comp.lang.c mailing list