]> wimlib.net Git - wimlib/commitdiff
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 ead4629583d9eec3b270eb495aefb121ac248766..473f5e2578f4b88e7907ae4466f7e26371506c22 100644 (file)
@@ -28,7 +28,7 @@
 #define DEFINE_UNALIGNED_TYPE(type)                            \
 struct type##_unaligned {                                      \
        type v;                                                 \
 #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)                         \
                                                                \
 static forceinline type                                                \
 load_##type##_unaligned(const void *p)                         \