The following two declarations work under gcc 4.2.4, but are inconsistent under gcc 4.4.1:
static inline void put_unaligned_uint64(void *p, uint64_t datum) { struct { uint64_t d; } __attribute__((packed)) *pp = p; pp->d = datum; } static inline void put_unaligned_uint32(void *p, unsigned int datum) { struct { unsigned int d; } __attribute__((packed)) *pp = p; pp->d = datum; } Given that the only difference between these two functions is that one is 64-bit, while the other is 32-bit, they should either both fail under strict aliasing rules or they should both succeed with no error. The error reported under gcc 4.4.1 is as follows: /home/tilghman/Asterisk/asterisk-trunk/include/asterisk/unaligned.h:55: error: dereferencing pointer âppâ does break strict-aliasing rules /home/tilghman/Asterisk/asterisk-trunk/include/asterisk/unaligned.h:53: note: initialized from here -- Summary: [4.4 regression] packed 64-bit field reports as violation of strict aliasing rules Product: gcc Version: 4.4.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: tlesher at digium dot com GCC host triplet: x86_64-linux-gnu GCC target triplet: x86_64-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42103