When compiling xz_dec_stream.c with GCC 7.1.0, it complains thusly:
In function 'dec_stream_footer':
error: dereferencing type-punned pointer will break strict-aliasing
rules [-Werror=strict-aliasing]
if (xz_crc32(s->temp.buf + 4, 6, 0) != get_le32(s->temp.buf))
^~
The thing is, the `buf` field was put just after two fields of type
size_t for the express purpose of avoiding alignment issues, as per the
comment above the `temp` struct.
Meaning: GCC gets this all wrong and should not complain. So let's force
it to be quiet for a couple of lines.
Signed-off-by: Johannes Schindelin <[email protected]>
---
archival/libarchive/unxz/xz_dec_stream.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/archival/libarchive/unxz/xz_dec_stream.c
b/archival/libarchive/unxz/xz_dec_stream.c
index bf791055b..8131ee30a 100644
--- a/archival/libarchive/unxz/xz_dec_stream.c
+++ b/archival/libarchive/unxz/xz_dec_stream.c
@@ -423,6 +423,15 @@ static enum xz_ret XZ_FUNC dec_stream_footer(struct xz_dec
*s)
if (!memeq(s->temp.buf + 10, FOOTER_MAGIC, FOOTER_MAGIC_SIZE))
return XZ_DATA_ERROR;
+#if defined(__GNUC__)
+ /*
+ * The temp.buf field is put just after two fields of type size_t for
+ * the express purpose of avoiding alignment issues. But GCC complains
+ * about it nevertheless... so: shut GCC up for a few lines.
+ */
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wstrict-aliasing"
+#endif
if (xz_crc32(s->temp.buf + 4, 6, 0) != get_le32(s->temp.buf))
return XZ_DATA_ERROR;
@@ -433,6 +442,9 @@ static enum xz_ret XZ_FUNC dec_stream_footer(struct xz_dec
*s)
*/
if ((s->index.size >> 2) != get_le32(s->temp.buf + 4))
return XZ_DATA_ERROR;
+#if defined(__GNUC__)
+#pragma GCC diagnostic pop
+#endif
if (s->temp.buf[8] != 0 || s->temp.buf[9] != s->check_type)
return XZ_DATA_ERROR;
base-commit: 4dea1edd08a45c5987448719e56ee61a20fb9210
--
2.14.0.windows.1.2.g0f3342804fc
Published-As:
https://github.com/dscho/busybox-w32/releases/tag/busybox-type-punned-warning-v1
Fetch-It-Via: git fetch https://github.com/dscho/busybox-w32
busybox-type-punned-warning-v1
_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox