pkgsrc-Changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: CVS commit: pkgsrc/net/libfetch



On 10/15/2012 17:40, Greg Troxel wrote:
"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.


Yes, the warning is correct.  That's why it had to be disabled.
To avoid a warning with strict-aliasing checking would require recoding. That's a better long-term solution but I'll leave it to the maintainers of libfetch to determine if they want to rewrite the code.

John



Home | Main Index | Thread Index | Old Index