-
Notifications
You must be signed in to change notification settings - Fork 14.6k
Closed
Labels
Description
[270/361] Building CXX object projects/libc/src/signal/linux/CMakeFiles/libc.src.signal.linux.raise.dir/raise.cpp.o
In file included from /android0/llvm-project/libc/src/signal/linux/raise.cpp:10:
/android0/llvm-project/libc/src/signal/linux/signal_utils.h: In member function ‘__llvm_libc_18_0_0_git::KernelSigaction& __llvm_libc_18_0_0_git::KernelSigaction::operator=(const sigaction&)’:
/android0/llvm-project/libc/src/signal/linux/signal_utils.h:38:20: warning: cast between incompatible function types from ‘void (*)(int, siginfo_t*, void*)’ to ‘void (*)(int)’ [-Wcast-function-type]
38 | sa_handler = reinterpret_cast<HandlerType *>(sa.sa_sigaction);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/android0/llvm-project/libc/src/signal/linux/signal_utils.h: In member function ‘__llvm_libc_18_0_0_git::KernelSigaction::operator sigaction() const’:
/android0/llvm-project/libc/src/signal/linux/signal_utils.h:51:25: warning: cast between incompatible function types from ‘void (*)(int)’ to ‘void (*)(int, siginfo_t*, void*)’ [-Wcast-function-type]
51 | sa.sa_sigaction = reinterpret_cast<SiginfoHandlerType *>(sa_handler);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I'm trying to get -Werror re-enabled in #74506; building with GCC flags the above warning.
Metadata
Metadata
Assignees
Labels
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
llvmbot commentedon Dec 6, 2023
@llvm/issue-subscribers-libc
Author: Nick Desaulniers (nickdesaulniers)
nickdesaulniers commentedon Dec 6, 2023
https://android.googlesource.com/platform/bionic/+/refs/heads/main/libc/include/bits/signal_types.h?autodive=0%2F%2F#60
alludes to the issue that is mentioned near the warning.
llvm-project/libc/src/signal/linux/signal_utils.h
Lines 21 to 22 in 1f283a6
SchrodingerZhu commentedon Dec 6, 2023
Casting to an intermediate value should suppress the warning. See https://godbolt.org/z/PncMfvfz7
nickdesaulniers commentedon Dec 6, 2023
Sure, we can probably get by with laundering the type through a
void*
. Though the comment in bionic makes me think that our current implementation is wrong; or might need to be adjusted further in the future.SchrodingerZhu commentedon Dec 6, 2023
Would
HandlerType = void (*) (int, ...)
work then?Casting around
will just work without warning. Per
psABI
's view, it seems to be safe enough.However, I suppose you are talking about separating them based on implementations rather than figuring out an generic type that just works.
[libc] fix -Wcast-function-type via union rather than reinterpret_cast
[libc] fix -Wcast-function-type via union rather than reinterpret_cast (