increment casted void pointer -- ANSI?

Doug Gwyn gwyn at smoke.brl.mil
Wed Apr 3 08:02:43 AEST 1991


In article <718q01zZ4fNC00 at amdahl.uts.amdahl.com> nw at uts.amdahl.com (Neal Weidenhofer) writes:
>behavior is implementation-defined."  I know we all discussed support
>for type punning using unions, but it doesn't seem to be required.
>The footnote clearly indicates that we intended it to work but
>footnotes are, alas, not a part of the standard.
>So, as far as I can see, no hoop jumping is required if the
>implementation writers/distributors document the fact.  It seems to be
>another quality-of-implementation issue.

Yes, I agree with that assessment.  While the behavior is defined,
not undefined, it needn't be defined to "do the right thing".
I would suggest, however, that implementations SHOULD do the obvious
thing for mixed access to unions in all cases where the member types
share the same (physical) address space.  Thus, using a union to
perform the type punning must be accepted by the compiler, and
ought to actually perform the pun correctly in the vast majority of
environments.  (While we were able to imagine an environment where
floating and integral types were maintained in separate address
spaces, I don't know of any actual implementations like that.)



More information about the Comp.lang.c mailing list