http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46078
Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED Resolution| |INVALID --- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> 2010-11-29 18:04:52 UTC --- As I said earlier, libcpp warnings aren't actually bugs. For the zlib warnings, here is a standalone testcase: #include <zlib.h> #include <stdlib.h> #include <string.h> static void * lto_zalloc (void *opaque, unsigned items, unsigned size) { void *p = malloc (items * size); // memset (p, 0xaa, items * size); return p; } static void lto_zfree (void *opaque, void *address) { free (address); } /* #define lto_zalloc NULL */ /* #define lto_zfree NULL */ __attribute__((noinline, noclone)) void lto_end_compression (unsigned char *cursor, size_t remaining) { const size_t outbuf_length = 4096; unsigned char *outbuf = (unsigned char *) malloc (outbuf_length); z_stream out_stream; size_t compressed_bytes = 0; int status; out_stream.next_out = outbuf; out_stream.avail_out = outbuf_length; out_stream.next_in = cursor; out_stream.avail_in = remaining; out_stream.zalloc = lto_zalloc; out_stream.zfree = lto_zfree; out_stream.opaque = Z_NULL; status = deflateInit (&out_stream, Z_DEFAULT_COMPRESSION); if (status != Z_OK) abort (); size_t in_bytes, out_bytes; status = deflate (&out_stream, Z_FINISH); if (status != Z_STREAM_END) abort (); in_bytes = remaining - out_stream.avail_in; out_bytes = outbuf_length - out_stream.avail_out; compressed_bytes += out_bytes; cursor += in_bytes; remaining -= in_bytes; out_stream.next_out = outbuf; out_stream.avail_out = outbuf_length; out_stream.next_in = cursor; out_stream.avail_in = remaining; status = deflateEnd (&out_stream); if (status != Z_OK) abort (); } unsigned char blob[1024] = { 1, 0, 0, 0, 10, 0, 0, 0, 0x58, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 8, 2, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0x80, 0, 0, 0xab, 3, 0, 0, 0, 0, 0, 0, 1, 6, 0, 0, 0, 0, 0, 0, 0, 0x78, 0x38, 0x36, 0x2d, 0x36, 0x34, 1, 0, 0, 0, 0, 0x80, 0, 0, 0xef, 3, 0, 0, 0, 0, 0, 0, 1, 7, 0, 0, 0, 0, 0, 0, 0, 0x67, 0x65, 0x6e, 0x65, 0x72, 0x69, 0x63, 1, 0, 0, 0 }; int main (void) { lto_end_compression (blob, 104); return 0; } on which valgrind warns when it is linked against gcc's libz.a (but not when linked against Fedora 14 libz.so). But http://zlib.net/zlib_faq.html#faq36 says this is not a bug either. zlib 1.2.4 nevertheless has some changes in fill_window etc. which memset the area.