From 2098d4034d398cbde6ccd4a2aaac52c518374698 Mon Sep 17 00:00:00 2001 From: Joseph Myers Date: Fri, 30 Oct 2020 21:38:31 +0000 Subject: Disable spurious -Wstringop-overflow for setjmp/longjmp (bug 26647) Building glibc with GCC 11 fails with (among other warnings) spurious -Wstringop-overflow warnings from calls to setjmp and longjmp with a pointer to a pthread_unwind_buf that is smaller than jmp_buf. As discussed in bug 26647, the warning in libc-start.c is a false positive, because setjmp and longjmp do not access anything (the signal mask) beyond the common prefix of the two structures, so this patch disables the warning for that call to setjmp, as well as for two calls in NPTL code that produce the same warning and look like false positives for the same reason. Tested with build-many-glibcs.py for arm-linux-gnueabi, where this allows the build to get further. Reviewed-by: DJ Delorie --- nptl/unwind.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'nptl/unwind.c') diff --git a/nptl/unwind.c b/nptl/unwind.c index 35ed2a7b10..8f157e49f4 100644 --- a/nptl/unwind.c +++ b/nptl/unwind.c @@ -23,6 +23,7 @@ #include #include #include "pthreadP.h" +#include #include #ifdef _STACK_GROWS_DOWN @@ -90,8 +91,17 @@ unwind_stop (int version, _Unwind_Action actions, } } + DIAG_PUSH_NEEDS_COMMENT; +#if __GNUC_PREREQ (7, 0) + /* This call results in a -Wstringop-overflow warning because struct + pthread_unwind_buf is smaller than jmp_buf. setjmp and longjmp + do not use anything beyond the common prefix (they never access + the saved signal mask), so that is a false positive. */ + DIAG_IGNORE_NEEDS_COMMENT (11, "-Wstringop-overflow="); +#endif if (do_longjump) __libc_unwind_longjmp ((struct __jmp_buf_tag *) buf->cancel_jmp_buf, 1); + DIAG_POP_NEEDS_COMMENT; return _URC_NO_REASON; } -- cgit v1.2.3