increment casted void pointer -- ANSI?

Doug Gwyn gwyn at smoke.brl.mil
Fri Mar 29 08:43:40 AEST 1991


In article <3492 at inews.intel.com> bhoughto at pima.intel.com (Blair P. Houghton) writes:
-In article <15589 at smoke.brl.mil> gwyn at smoke.brl.mil (Doug Gwyn) writes:
->In article <288 at nazgul.UUCP> bright at nazgul.UUCP (Walter Bright) writes:
->-In article <1991Mar8.165300.11692 at zoo.toronto.edu> henry at zoo.toronto.edu (Henry Spencer) writes:
->-/There is no way to say "pretend this variable has a different type" in C.
->-The usual to do a 'type paint', which is to change the type of an object
->A strictly conforming method is to use a union type.
-Where in the std is it prohibited to fake unions by using a struct
-and externally prohibiting attempts to dereference a value
-that was superseded by one of a different type?

There are constraints on what is strictly conforming use of pointed-to
objects, etc.

-It seems to say only that a union has to be at least large enough
-to hold it's member with the most bits, and to align members
-suitably, but not that it has to overlap types.

Sure it "overlaps", or acts as if it did.  A conforming implementation
that, e.g. stores floating-point data in a different address space from
integer data may have to jump through hoops if it wishes to make the
aliasing of the representations actually work.  However, such a program
would have to be successfully translated, it just may not work right (in
which case the fake pointer business would probably malfunction too).



More information about the Comp.std.c mailing list