aboutsummaryrefslogtreecommitdiffstats
path: root/src/bytecode.c
diff options
context:
space:
mode:
authorPaul Eggert2024-08-16 16:29:51 -0700
committerPaul Eggert2024-08-16 21:16:35 -0700
commit2169a9387a5ac22b969d37ece4ec1aaa0fd830d9 (patch)
tree52eb6078bf4cbc03bb9142a77216b989deddd474 /src/bytecode.c
parent909d1d02db1c11e1309316cba2a392e1456e6053 (diff)
downloademacs-2169a9387a5ac22b969d37ece4ec1aaa0fd830d9.tar.gz
emacs-2169a9387a5ac22b969d37ece4ec1aaa0fd830d9.zip
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.
Diffstat (limited to 'src/bytecode.c')
-rw-r--r--src/bytecode.c24
1 files 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/>. */
29#include "window.h" 29#include "window.h"
30#include "puresize.h" 30#include "puresize.h"
31 31
32/* Work around GCC bug 54561. */
33#if GNUC_PREREQ (4, 3, 0)
34# pragma GCC diagnostic ignored "-Wclobbered"
35#endif
36
37/* Define BYTE_CODE_SAFE true to enable some minor sanity checking, 32/* Define BYTE_CODE_SAFE true to enable some minor sanity checking,
38 useful for debugging the byte compiler. It defaults to false. */ 33 useful for debugging the byte compiler. It defaults to false. */
39 34
@@ -536,6 +531,12 @@ exec_byte_code (Lisp_Object fun, ptrdiff_t args_template,
536 for (ptrdiff_t i = nargs - rest; i < nonrest; i++) 531 for (ptrdiff_t i = nargs - rest; i < nonrest; i++)
537 PUSH (Qnil); 532 PUSH (Qnil);
538 533
534 unsigned char volatile saved_quitcounter;
535#if GCC_LINT && __GNUC__ && !__clang__
536 Lisp_Object *volatile saved_vectorp;
537 unsigned char const *volatile saved_bytestr_data;
538#endif
539
539 while (true) 540 while (true)
540 { 541 {
541 int op; 542 int op;
@@ -967,15 +968,23 @@ exec_byte_code (Lisp_Object fun, ptrdiff_t args_template,
967 968
968 if (sys_setjmp (c->jmp)) 969 if (sys_setjmp (c->jmp))
969 { 970 {
971 quitcounter = saved_quitcounter;
970 struct handler *c = handlerlist; 972 struct handler *c = handlerlist;
971 handlerlist = c->next; 973 handlerlist = c->next;
972 top = c->bytecode_top; 974 top = c->bytecode_top;
973 op = c->bytecode_dest; 975 op = c->bytecode_dest;
976 bc = &current_thread->bc;
974 struct bc_frame *fp = bc->fp; 977 struct bc_frame *fp = bc->fp;
975 978
976 Lisp_Object fun = fp->fun; 979 Lisp_Object fun = fp->fun;
977 Lisp_Object bytestr = AREF (fun, CLOSURE_CODE); 980 Lisp_Object bytestr = AREF (fun, CLOSURE_CODE);
978 Lisp_Object vector = AREF (fun, CLOSURE_CONSTANTS); 981 Lisp_Object vector = AREF (fun, CLOSURE_CONSTANTS);
982#if GCC_LINT && __GNUC__ && !__clang__
983 /* These useless assignments pacify GCC 14.2.1 x86-64
984 <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=21161>. */
985 bytestr_data = saved_bytestr_data;
986 vectorp = saved_vectorp;
987#endif
979 bytestr_data = SDATA (bytestr); 988 bytestr_data = SDATA (bytestr);
980 vectorp = XVECTOR (vector)->contents; 989 vectorp = XVECTOR (vector)->contents;
981 if (BYTE_CODE_SAFE) 990 if (BYTE_CODE_SAFE)
@@ -989,6 +998,11 @@ exec_byte_code (Lisp_Object fun, ptrdiff_t args_template,
989 goto op_branch; 998 goto op_branch;
990 } 999 }
991 1000
1001 saved_quitcounter = quitcounter;
1002#if GCC_LINT && __GNUC__ && !__clang__
1003 saved_vectorp = vectorp;
1004 saved_bytestr_data = bytestr_data;
1005#endif
992 NEXT; 1006 NEXT;
993 } 1007 }
994 1008