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.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user