Skip to content

Conversation

@kmemarian
Copy link
Collaborator

The previously used -Wcast-function-type also enables -Wcast-function-type-strict on recent versions of Clang. This does not like casts turning function parameter types to void * (which happens throughout cn-smt/). This stricter check is only relevant when using CFI.

@kmemarian kmemarian requested a review from pqwy December 8, 2025 16:11
@kmemarian
Copy link
Collaborator Author

:-(, gcc doesn't know that flag (and now I realised probably neither do older clangs). Not sure what is the best approach to make every compilers happy then.

@msaljuk
Copy link

msaljuk commented Dec 10, 2025

:-(, gcc doesn't know that flag (and now I realised probably neither do older clangs). Not sure what is the best approach to make every compilers happy then.

I was running into this too. Short of rewriting the code to not cast to void ptrs, would it be feasible to relax -Wcast-function-type just around the offending callsites with a #pragma GCC diagnostic ignored?

@pqwy
Copy link
Contributor

pqwy commented Dec 12, 2025

We can delete -Wcast-function-type and work from there.

The warning comes from adding a subset of what Linux uses to the build. As it is, various warnings still need to be turned off when compiling as part of Linux, so enforcing this particular one does not improve things drastically.

@dc-mak
Copy link
Contributor

dc-mak commented Dec 12, 2025

what about a clang pragma aroud the offending code? https://stackoverflow.com/questions/48426484/concise-way-to-disable-specific-warning-instances-in-clang

there might be a way to do so for only specific versions of clang if the pragma is not backwards compatible

@dc-mak
Copy link
Contributor

dc-mak commented Dec 12, 2025

E.g. something like this (not tested, just a suggestion).

#if defined(__clang__)
#  if __has_warning("-Wcast-function-type-strict")
#    pragma clang diagnostic push
#    pragma clang diagnostic ignored "-Wcast-function-type-strict"
#  endif
#endif

/* cast that triggers the warning */

#if defined(__clang__)
#  if __has_warning("-Wcast-function-type-strict")
#    pragma clang diagnostic pop
#  endif
#endif

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants