]> git.ipfire.org Git - thirdparty/glibc.git/commit - sysdeps/nptl/pthread.h
Avoid -Wstringop-overflow warning in pthread_cleanup_push macros
authorJoseph Myers <joseph@codesourcery.com>
Fri, 30 Oct 2020 22:25:42 +0000 (22:25 +0000)
committerJoseph Myers <joseph@codesourcery.com>
Fri, 30 Oct 2020 22:25:42 +0000 (22:25 +0000)
commit548f467fa14ffe7d955beeb31b30e2aeae4467e0
tree110b58e4d121c3650cb103a883f02091d06c5e84
parent882774658cb8daee4c16677a3fd674f6052cc157
Avoid -Wstringop-overflow warning in pthread_cleanup_push macros

GCC 11 introduces a -Wstringop-overflow warning for calls to functions
with an array argument passed as a pointer to memory not large enough
for that array.  This includes the __sigsetjmp calls from
pthread_cleanup_push macros, because those use a structure in
__pthread_unwind_buf_t, which has a common initial subsequence with
jmp_buf but does not include the saved signal mask; this is OK in this
case because the second argument to __sigsetjmp is 0 so the signal
mask is not accessed.

To avoid this warning, use a function alias __sigsetjmp_cancel with
first argument an array of exactly the type used in the calls to the
function, if using GCC 11 or later.  With older compilers, continue to
use __sigsetjmp with a cast, to avoid any issues with compilers
predating the returns_twice attribute not applying the same special
handling to __sigsetjmp_cancel as to __sigsetjmp.

Tested with build-many-glibcs.py for arm-linux-gnueabi that this fixes
the testsuite build failures.
misc/sys/cdefs.h
sysdeps/nptl/pthread.h