bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

sigsegv: Fix a compilation error on OpenBSD with clang ≥ 16


From: Bruno Haible
Subject: sigsegv: Fix a compilation error on OpenBSD with clang ≥ 16
Date: Sat, 11 Feb 2023 18:53:46 +0100

When clang 16 will be released, it will signal an error by default, instead
of a warning, for implicit function pointer type conversions.

Example (with clang 16.0.0 rc2):

================= foo.c =============
struct ucontext_t;
int (*f) (int, void *);
int (*g) (int, struct ucontext_t *);

void assign(void) {
    f = g;
}
=====================================

$ clang -S foo.c
foo.c:6:7: error: incompatible function pointer types assigning to 'int 
(*)(int, void *)' from 'int (*)(int, struct ucontext_t *)' 
[-Wincompatible-function-pointer-types]
    f = g;
      ^ ~
1 error generated.

The fix is to add a cast.

As in this case (relevant only for OpenBSD).


2023-02-11  Bruno Haible  <bruno@clisp.org>

        sigsegv: Fix a compilation error on OpenBSD with clang ≥ 16.
        * lib/sigsegv.c (install_for): Add a cast when assigning to
        action.sa_sigaction.

diff --git a/lib/sigsegv.c b/lib/sigsegv.c
index 29c452dbe0..5e943e4d5d 100644
--- a/lib/sigsegv.c
+++ b/lib/sigsegv.c
@@ -1211,7 +1211,7 @@ install_for (int sig)
   struct sigaction action;
 
 # ifdef SIGSEGV_FAULT_ADDRESS_FROM_SIGINFO
-  action.sa_sigaction = &sigsegv_handler;
+  action.sa_sigaction = (void (*) (int, siginfo_t *, void *)) &sigsegv_handler;
 # else
   action.sa_handler = (void (*) (int)) &sigsegv_handler;
 # endif






reply via email to

[Prev in Thread] Current Thread [Next in Thread]