Type punning in C

Keith Bierman - SPD Advanced Languages khb%chiba at Sun.COM
Fri Oct 13 11:10:32 AEST 1989


In article <1989Oct11.091619.18336 at gdt.bath.ac.uk> exspes at 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.  This is a
>polite way of saying (to the user) 'this trick may not work', and (to
>the

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 ?

>
>Fortran equivalence was designed toallow reuse of storage on the early
>small memory machines -- not to allow type punning.  Usually you can
>get away with punning, but it doesn't always work and so is a bad habit.
>

On which systems (if any) have you seen this not work ?


Keith H. Bierman    |*My thoughts are my own. !! kbierman at sun.com
It's Not My Fault   |	MTS --Only my work belongs to Sun* 
I Voted for Bill &  | Advanced Languages/Floating Point Group            
Opus                | "When the going gets Weird .. the Weird turn PRO"



More information about the Comp.lang.c mailing list