unaligned: use may_alias attribute
authorEric Biggers <ebiggers3@gmail.com>
Sun, 16 Jul 2017 06:26:33 +0000 (23:26 -0700)
committerEric Biggers <ebiggers3@gmail.com>
Sun, 16 Jul 2017 06:26:33 +0000 (23:26 -0700)
gcc7 miscompiles the "undo" mode of translate_if_needed() in
lzms_common.c because the get_unaligned_le16() was incorrectly being
moved before the put_unaligned_le32().  Fix it by marking the special
"unaligned" structs with the may_alias attribute.

include/wimlib/unaligned.h

index ead4629..473f5e2 100644 (file)
@@ -28,7 +28,7 @@
 #define DEFINE_UNALIGNED_TYPE(type)                            \
 struct type##_unaligned {                                      \
        type v;                                                 \
-} _packed_attribute;                                           \
+} _packed_attribute _may_alias_attribute;                      \
                                                                \
 static forceinline type                                                \
 load_##type##_unaligned(const void *p)                         \