"John Marino"<marino%netbsd.org@localhost> writes:
When building with gcc4.7, libfetch fails with the following error:
ftp.c: In function 'unmappedaddr':
ftp.c:149:2: error: dereferencing type-punned pointer will break
strict-aliasing rules [-Werror=strict-aliasing]
cc1: all warnings being treated as errors
*** Error code 1
The code is intentionally grouping an array of four uint8_t bytes into a
uint32_t word. Add -Wno-strict-aliasing in makefile to fix build in gcc4.7.
But isn't the warning correct, in that dereferencing a uint32 pointer
does not guarantee data coherency for objects of other types? AIUI, in
C99, the compiler is free to let objects of type other than foo have
inconsistent values while a foo* is being dereferenced, and is only
obligated to ensure consistency of objects of type foo. It seems in
modern C, one must use a union for such overlays.