On Wed, Jun 24, 2020 at 01:43:13PM +0200, SZEDER Gábor wrote: > > static uint32_t counter = 1; /* avoid null oid */ > > const unsigned hashsz = the_hash_algo->rawsz; > > - unsigned char *out = xcalloc(hashsz, 1); > > - put_be32(out + hashsz - 4, counter++); > > - return out; > > + struct object_id oid; > > + char *hex = xmallocz(GIT_MAX_HEXSZ); > > + > > + oidclr(&oid); > > + put_be32(oid.hash + hashsz - 4, counter++); > > + return oid_to_hex_r(hex, &oid); > > } > > GCC 4.8 complains about this change in our CI job: > > $ make CC=gcc-4.8 builtin/fast-export.o > CC builtin/fast-export.o > builtin/fast-export.c: In function ‘generate_fake_oid’: > builtin/fast-export.c:394:2: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing] > put_be32(oid.hash + hashsz - 4, counter++); > ^ > cc1: all warnings being treated as errors Interesting. The only change on this line is swapping out the local "unsigned char *" for an object_id, which also stores an "unsigned char" (though as an array). And while put_be32() takes a void pointer, it's inlined and treats it the argument an "unsigned char *" internally. So I'm not sure I see that any type punning is going on at all. I'll see if I can appease the compiler, though. -Peff