emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 0c11c2ae71f 10/16: Pacify GCC 13 -Wanalyzer-out-of-bounds


From: Paul Eggert
Subject: master 0c11c2ae71f 10/16: Pacify GCC 13 -Wanalyzer-out-of-bounds
Date: Sun, 14 May 2023 22:28:25 -0400 (EDT)

branch: master
commit 0c11c2ae71fcc03d98b35384d6c70e6d7454ba90
Author: Paul Eggert <eggert@cs.ucla.edu>
Commit: Paul Eggert <eggert@cs.ucla.edu>

    Pacify GCC 13 -Wanalyzer-out-of-bounds
    
    * src/alloc.c (NEAR_STACK_TOP): Hoist from here ...
    * src/thread.h: ... to here.
    * src/print.c (print_object): Use NEAR_STACK_TOP instead of raw
    buffer address.  This is more natural, and pacifies GCC 13.
---
 src/alloc.c  | 9 ---------
 src/print.c  | 2 +-
 src/thread.h | 9 +++++++++
 3 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/src/alloc.c b/src/alloc.c
index 6391ede8d0a..29393deeff4 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -5338,15 +5338,6 @@ typedef union
 #endif
 } stacktop_sentry;
 
-/* Yield an address close enough to the top of the stack that the
-   garbage collector need not scan above it.  Callers should be
-   declared NO_INLINE.  */
-#ifdef HAVE___BUILTIN_FRAME_ADDRESS
-# define NEAR_STACK_TOP(addr) ((void) (addr), __builtin_frame_address (0))
-#else
-# define NEAR_STACK_TOP(addr) (addr)
-#endif
-
 /* Set *P to the address of the top of the stack.  This must be a
    macro, not a function, so that it is executed in the caller's
    environment.  It is not inside a do-while so that its storage
diff --git a/src/print.c b/src/print.c
index e65b4c40b0e..6320c38fc6b 100644
--- a/src/print.c
+++ b/src/print.c
@@ -2204,7 +2204,7 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, 
bool escapeflag)
                     max ((sizeof " with data 0x"
                           + (sizeof (uintmax_t) * CHAR_BIT + 4 - 1) / 4),
                          40)))];
-  current_thread->stack_top = buf;
+  current_thread->stack_top = NEAR_STACK_TOP (buf);
 
  print_obj:
   maybe_quit ();
diff --git a/src/thread.h b/src/thread.h
index f0e9ee01173..9b14cc44f35 100644
--- a/src/thread.h
+++ b/src/thread.h
@@ -33,6 +33,15 @@ along with GNU Emacs.  If not, see 
<https://www.gnu.org/licenses/>.  */
 #include "sysselect.h"         /* FIXME */
 #include "systhread.h"
 
+/* Yield an address close enough to the top of the stack that the
+   garbage collector need not scan above it.  Callers should be
+   declared NO_INLINE.  */
+#ifdef HAVE___BUILTIN_FRAME_ADDRESS
+# define NEAR_STACK_TOP(addr) ((void) (addr), __builtin_frame_address (0))
+#else
+# define NEAR_STACK_TOP(addr) (addr)
+#endif
+
 INLINE_HEADER_BEGIN
 
 /* Byte-code interpreter thread state.  */



reply via email to

[Prev in Thread] Current Thread [Next in Thread]