[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 2169a9387a5 1/7: Don’t ignore -Wclobbered in bytecode.c
From: |
Paul Eggert |
Subject: |
master 2169a9387a5 1/7: Don’t ignore -Wclobbered in bytecode.c |
Date: |
Sat, 17 Aug 2024 00:16:46 -0400 (EDT) |
branch: master
commit 2169a9387a5ac22b969d37ece4ec1aaa0fd830d9
Author: Paul Eggert <eggert@cs.ucla.edu>
Commit: Paul Eggert <eggert@cs.ucla.edu>
Don’t ignore -Wclobbered in bytecode.c
This fix is prompted by Emacs bug#71744.
The working hypothesis is that there are some bugs in Emacs,
and some in GCC’s diagnostics, and that this patch
fixes the Emacs bugs and works around the GCC diagnostic bugs.
The hypothesis is that GCC diagnostic bugs occur when GCC
coalesces variables or temporaries and some variables
are clobbered by setjmp and some vars/temps are not.
Part of this hypothesis involves GCC diagnosing the wrong variables.
Instead of ignoring the diagnostics, which the hypothesis suggests
indicate either problems in Emacs or in GCC, fix the Emacs bugs
and pacify the GCC false positives, with comments about the GCC bugs.
GCC’s true positives are helpful enough in squashing obscure bugs like
Emacs bug#71744, that it’s worth going to some effort to pacify
-Wclobbered instead of ignoring it.
* src/bytecode.c: Do not ignore -Wclobbered.
(exec_byte_code): Fix violations of the C standard, where setjmp
clobbered quitcounter and bc. If GCC_LINT && __GNUC__ && !__clang__,
work around GCC -Wclobbered warnings for bytestr_data and vectorp.
---
src/bytecode.c | 24 +++++++++++++++++++-----
1 file changed, 19 insertions(+), 5 deletions(-)
diff --git a/src/bytecode.c b/src/bytecode.c
index ce075c86afd..48a29c22d55 100644
--- a/src/bytecode.c
+++ b/src/bytecode.c
@@ -29,11 +29,6 @@ along with GNU Emacs. If not, see
<https://www.gnu.org/licenses/>. */
#include "window.h"
#include "puresize.h"
-/* Work around GCC bug 54561. */
-#if GNUC_PREREQ (4, 3, 0)
-# pragma GCC diagnostic ignored "-Wclobbered"
-#endif
-
/* Define BYTE_CODE_SAFE true to enable some minor sanity checking,
useful for debugging the byte compiler. It defaults to false. */
@@ -536,6 +531,12 @@ exec_byte_code (Lisp_Object fun, ptrdiff_t args_template,
for (ptrdiff_t i = nargs - rest; i < nonrest; i++)
PUSH (Qnil);
+ unsigned char volatile saved_quitcounter;
+#if GCC_LINT && __GNUC__ && !__clang__
+ Lisp_Object *volatile saved_vectorp;
+ unsigned char const *volatile saved_bytestr_data;
+#endif
+
while (true)
{
int op;
@@ -967,15 +968,23 @@ exec_byte_code (Lisp_Object fun, ptrdiff_t args_template,
if (sys_setjmp (c->jmp))
{
+ quitcounter = saved_quitcounter;
struct handler *c = handlerlist;
handlerlist = c->next;
top = c->bytecode_top;
op = c->bytecode_dest;
+ bc = ¤t_thread->bc;
struct bc_frame *fp = bc->fp;
Lisp_Object fun = fp->fun;
Lisp_Object bytestr = AREF (fun, CLOSURE_CODE);
Lisp_Object vector = AREF (fun, CLOSURE_CONSTANTS);
+#if GCC_LINT && __GNUC__ && !__clang__
+ /* These useless assignments pacify GCC 14.2.1 x86-64
+ <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=21161>. */
+ bytestr_data = saved_bytestr_data;
+ vectorp = saved_vectorp;
+#endif
bytestr_data = SDATA (bytestr);
vectorp = XVECTOR (vector)->contents;
if (BYTE_CODE_SAFE)
@@ -989,6 +998,11 @@ exec_byte_code (Lisp_Object fun, ptrdiff_t args_template,
goto op_branch;
}
+ saved_quitcounter = quitcounter;
+#if GCC_LINT && __GNUC__ && !__clang__
+ saved_vectorp = vectorp;
+ saved_bytestr_data = bytestr_data;
+#endif
NEXT;
}
- master updated (909d1d02db1 -> ed305c4b98c), Paul Eggert, 2024/08/17
- master ed305c4b98c 7/7: Fix x_construct_mouse_click || vs | typo, Paul Eggert, 2024/08/17
- master 2169a9387a5 1/7: Don’t ignore -Wclobbered in bytecode.c,
Paul Eggert <=
- master 1282714da55 3/7: Don’t ignore -Wclobbered in eval.c, Paul Eggert, 2024/08/17
- master 8c81818673a 6/7: Tune volatile in read_char, Paul Eggert, 2024/08/17
- master cfa5a634e91 2/7: Don’t ignore -Wclobbered in emacs-module.c, Paul Eggert, 2024/08/17
- master 3b24ac53885 4/7: Don’t ignore -Wclobbered in image.c, Paul Eggert, 2024/08/17
- master a967efdd2a5 5/7: Don’t ignore -Wclobbered in keyboard.c, Paul Eggert, 2024/08/17