http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59520
--- Comment #6 from joseph at codesourcery dot com <joseph at codesourcery dot com> --- On Fri, 20 Dec 2013, su at cs dot ucdavis.edu wrote: > In particular, are the following well-defined according the standard or they > have undefined behavior? In both cases, you are accessing uninitialized padding bits. ISO C allows for the possibility of type punning through unions (in a footnote added in C99 TC3, not in normative text), but this is still uninitialized data. Whether accesses to uninitialized data are completely undefined behavior, or only produce unspecified values in some cases, is less clear. See N1747 and the discussion under DR 451 in the draft Chicago minutes N1764. (Your examples concern padding bits in objects with static storage duration, rather than uninitialized objects with automatic storage duration, but the issues are much the same.) The general desire is to allow optimizations that may mean an uninitialized object does not act as if it has any consistent value, without making it undefined behavior to call memcpy (for example) on objects that may be only partly initialized.