Casting Function Pointers

Doug Gwyn gwyn at smoke.brl.mil
Mon May 27 12:08:21 AEST 1991


In article <1991May25.221756.16182 at zoo.toronto.edu> henry at zoo.toronto.edu (Henry Spencer) writes:
>In article <16259 at smoke.brl.mil> gwyn at smoke.brl.mil (Doug Gwyn) writes:
>>I'm not aware of any changes between the final draft of K&R2 (first printing)
>>and the official C standard that would make K&R2 less correct...
>I know of at least one -- it's no longer promised that casting a pointer to
>integer and back preserves its value if the integer is big enough -- and
>there are probably a few more.

X3.159-1989 Section 3.3.4 Semantics require that there be some such
implementation-defined type.  Well, actually, it doesn't require that
the "before" and "after" pointers compare equal, but that is clearly
the intent, for implementations where this is even possible.  There
can be some implementations with, say, 128-bit addresses and 64-bit
data words, for which some information would necessarily be lost by
the transformation.  Thus, while K&R2 section A6.6 technically
promises more than the C standard requires, it does indicate what the
intended behavior is, for implementations for which it is feasible.

Was that really changed during the public review process?  I don't
have the old drafts to look it up in.



More information about the Comp.std.c mailing list