git/builtin
Jeff King f39ad38410 fast-export: use local array to store anonymized oid
Some older versions of gcc complain about this line:

  builtin/fast-export.c:412:2: error: dereferencing type-punned pointer
       will break strict-aliasing rules [-Werror=strict-aliasing]
    put_be32(oid.hash + hashsz - 4, counter++);
    ^

This seems to be a false positive, as there's no type-punning at all
here. oid.hash is an array of unsigned char; when we pass it to a
function it decays to a pointer to unsigned char. We do take a void
pointer in put_be32(), but it's immediately aliased with another pointer
to unsigned char (and clearly the compiler is looking inside the inlined
put_be32(), since the warning doesn't happen with -O0).

This happens on gcc 4.8 and 4.9, but not later versions (I tested gcc 6,
7, 8, and 9).

We can work around it by using a local array instead of an object_id
struct. This is a little more intimate with the details of object_id,
but for whatever reason doesn't seem to trigger the compiler warning.
We can revert this patch once we decide that those gcc versions are too
old to care about for a warning like this (gcc 4.8 is the default
compiler for Ubuntu Trusty, which is out-of-support but not fully
end-of-life'd until April 2022).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2020-06-25 14:19:23 -07:00
..
2020-04-28 10:47:10 -07:00
2020-05-05 14:54:27 -07:00
2019-11-11 11:46:29 +09:00
2020-04-28 10:47:10 -07:00
2020-06-08 18:06:30 -07:00
2020-05-05 14:54:27 -07:00
2020-05-13 12:19:19 -07:00
2020-03-24 15:04:43 -07:00
2020-05-24 19:39:39 -07:00
2020-05-05 14:54:27 -07:00
2020-05-01 13:39:59 -07:00
2020-05-05 14:54:27 -07:00
2019-05-13 14:22:54 +09:00
2020-04-28 10:47:10 -07:00
2020-03-24 15:04:44 -07:00
2020-05-13 12:19:18 -07:00
2020-05-05 14:54:27 -07:00
2020-05-13 12:19:19 -07:00
2020-04-28 10:47:10 -07:00
2020-05-13 12:19:18 -07:00
2020-04-28 10:47:10 -07:00
2020-05-13 12:19:18 -07:00
2020-04-28 10:47:10 -07:00
2020-04-28 10:47:10 -07:00
2019-06-19 08:19:21 -07:00