Subject: gzip 1.9 alignment compile failure on cast
From: "Adler, Mark" <[email-masked]>
To: "[email-masked]" <[email-masked]>
Date: Wed, 28 Nov 2018 19:22:56 +0000
List-Id: <debbugs-submit.debbugs.gnu.org>

Compiling gzip 1.9 on macOS 10.13.6 using Xcode 10.1 with clang (Apple LLVM version 10.0.0 (clang-1000.11.45.5)), I get this error after ./configure and make:

memrchr.c:71:18: error: cast from 'const unsigned char *' to 'const longword *'
      (aka 'const unsigned long *') increases required alignment from 1 to 8
      [-Werror,-Wcast-align]
  longword_ptr = (const longword *) char_ptr;

I resolved it with this patch:

@@ -68,7 +68,7 @@ __memrchr (void const *s, int c_in, size_t n)
     if (*--char_ptr == c)
       return (void *) char_ptr;
 
-  longword_ptr = (const longword *) char_ptr;
+  longword_ptr = (const void *) char_ptr;
 
   /* All these elucidatory comments refer to 4-byte longwords,
      but the theory applies equally well to any size longwords.  */

Mark