diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2023-05-14 18:51:23 -0700 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2023-05-14 19:28:12 -0700 |
commit | 0c11c2ae71fcc03d98b35384d6c70e6d7454ba90 (patch) | |
tree | 44ec42b4afb9795514005850ef50f378f1c6a0b6 | |
parent | 4fedd5af4cc53666277fbcfc3417c0d7e3201c1d (diff) | |
download | emacs-0c11c2ae71fcc03d98b35384d6c70e6d7454ba90.tar.gz |
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.
-rw-r--r-- | src/alloc.c | 9 | ||||
-rw-r--r-- | src/print.c | 2 | ||||
-rw-r--r-- | 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. */ |