[clang] Split -Wcast-function-type into a separate group (PR #86131)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 14 08:06:49 PDT 2025


AaronBallman wrote:

> Since you aren't diagnosing reinterpret-casting a function pointer from `void*`, because this would warn on idiomatic POSIX code (`dlsym` returns `void*`), it seemed to me that you'd be interested in not warning on idiomatic Windows code (`GetProcAddress` returns `FARPROC`.)
> 
> But perhaps I was mistaken.

The idiomatic code doesn't diagnose?
```
#include <Windows.h>

typedef void (WINAPI *PGNSI)(LPSYSTEM_INFO);

int main() {
  HMODULE hLib = LoadLibrary("kernel32");
  PGNSI Ptr = reinterpret_cast<PGNSI>(GetProcAddress(hLib, "GetNativeSystemInfo"));
}
```
I get no diagnostics from this when I test on Windows, so I feel like I must be missing something.

https://github.com/llvm/llvm-project/pull/86131


More information about the cfe-commits mailing list