Issue 134867
Summary reinterpret_cast from const void* to function pointer does not compile
Labels new issue
Assignees
Reporter StilesCrisis
    GCC and MSVC both allow a reinterpret_cast to convert from a `const void*` to `void (*)(void*)`. 

Clang refuses because we are "casting away qualifiers" (const), but there is no qualifier to add on the function-pointer side. There is no syntax for assigning values into a function pointer and there is no possible addition of `const` into the function pointer type which makes the cast allowed.

This can be worked around by using const_cast to strip the const off the void*, or by using a C-style cast, but this seems like it shouldn't be necessary, and no other mainstream compiler requires it.

Example: https://godbolt.org/z/7rxqss7nT
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to