Subject: bug#47307: closed (Re: bug#47307: Emacs 27.2 RC2 build/check issues on macOS ARM64)

From: [email-masked] (GNU bug Tracking System)
Date: Thu, 25 Mar 2021 15:17:02 +0000

Your bug report

#47307: Emacs 27.2 RC2 build/check issues on macOS ARM64

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
47307: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=47307
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#47307: Emacs 27.2 RC2 build/check issues on macOS ARM64
From: Paul Eggert <[email-masked]>
To: Eli Zaretskii <[email-masked]>
Cc: [email-masked]
Date: Thu, 25 Mar 2021 08:16:12 -0700
List-Id: <debbugs-submit.debbugs.gnu.org>

On 3/22/21 10:20 AM, Eli Zaretskii wrote:
> I'm okay with installing this on the emacs-27 branch, but please wait
> until Emacs 27.2 is released

OK, done, and closing the bug report.

Subject: Emacs 27.2 RC2 build/check issues on macOS ARM64
From: Paul Eggert <[email-masked]>
To: Emacs bug reports and feature requests <[email-masked]>
Date: Sun, 21 Mar 2021 18:27:32 -0700
List-Id: <debbugs-submit.debbugs.gnu.org>

I configured Emacs 27.2 RC2 on macOS 11.2 ARM64 (arm-apple-darwin20.3.0) 
using "./configure --with-gnutls=ifavailable" (plain "./configure" 
failed, which was disconcerting). When I ran "make" the compiler complained:

editfns.c:2063:18: warning: unsequenced modification and access to 
'sa_avail' [-Wunsequenced]

This correctly diagnoses undefined behavior in that C function. I didn't 
investigate what happens on that platform is as it's easier to fix the 
problem on all platforms. I propose installing the attached 
obviously-safe patch into the emacs-27 branch.

There were several deprecation warnings when compiling but I assume we 
don't care about them in this older branch.

"make check" reported four unexpected failures. Perhaps a macOS expert 
could be persuaded to look into them. A tarball of the failed logs is 
attached.
From f85db942100f4a129d4b9efba5707b954cbf2121 Mon Sep 17 00:00:00 2001
From: Paul Eggert <[email-masked]>
Date: Sun, 21 Mar 2021 18:08:13 -0700
Subject: [PATCH] Fix replace-buffer-contents undefined behavior

* src/editfns.c (Freplace_buffer_contents): Avoid undefined
behavior with competing side effects in parallel subexpressions.
Problem reported by Apple clang version 12.0.0 (clang-1200.0.32.29).
---
 src/editfns.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/editfns.c b/src/editfns.c
index 621e35171d..cd9633d4c6 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -2053,6 +2053,8 @@ DEFUN ("replace-buffer-contents", Freplace_buffer_contents,
      code.  */
   ptrdiff_t del_bytes = (size_t) size_a / CHAR_BIT + 1;
   ptrdiff_t ins_bytes = (size_t) size_b / CHAR_BIT + 1;
+  unsigned char *deletions = SAFE_ALLOCA (del_bytes);
+  unsigned char *insertions = SAFE_ALLOCA (ins_bytes);
   struct context ctx = {
     .buffer_a = a,
     .buffer_b = b,
@@ -2060,8 +2062,8 @@ DEFUN ("replace-buffer-contents", Freplace_buffer_contents,
     .beg_b = min_b,
     .a_unibyte = BUF_ZV (a) == BUF_ZV_BYTE (a),
     .b_unibyte = BUF_ZV (b) == BUF_ZV_BYTE (b),
-    .deletions = SAFE_ALLOCA (del_bytes),
-    .insertions = SAFE_ALLOCA (ins_bytes),
+    .deletions = deletions,
+    .insertions = insertions,
     .fdiag = buffer + size_b + 1,
     .bdiag = buffer + diags + size_b + 1,
     .heuristic = true,
-- 
2.27.0