On 01/03/2010 12:52 PM, Andreas Schwab wrote: > Florian Weimer <f...@deneb.enyo.de> writes: > >> * Joshua Haberman: >> >>> To me this allows the following: >>> >>> int i; >>> union u { int x; } *pu = (union u*)&i; >>> printf("%d\n", pu->x); >> >> I think the cast on the secodn line is undefined, > > Only if union u has stricter alignment requirements than int; > otherwise you are guaranteed to get back the original pointer when > casting back to int*.
Right, but it's also important to point out that you can't dereference that pointer without undefined behaviour: all you can do is cast it back to an int*. Andrew.