David Laight wrote: > And I'm not sure that the compiler is required to treat the two > fields of the union as being the same data item. > Certainly if the fields of the union are 'void *' and 'intptr_t' > you can't assume that a value written to one field of the union > can be immediately read from the other. > > David >
My guess is that one cannot swap between different types (void * and intptr_t, being a pointer type and an integer type, respectively), but I would be inclined to think that char * and const char * do not differ in type, only in qualifier, so perhaps one could, in that case. However, I still have to consign this technique to the reject pile of those that do not make the grade. -- Andy.