lua-users home
lua-l archive

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


On Sat, Apr 25, 2020 at 9:42 AM Roberto Ierusalimschy <roberto@inf.puc-rio.br> wrote:
> I guess void(*)(void) is special because casting anything from/to void
> is considered safe by gcc .
>
> https://github.com/gcc-mirror/gcc/blob/master/gcc/cp/typeck.c#L1211-L1234

So far this points to a gcc kludge. Do you know whether this is documented
anywhere?
 
From the documentation of GCC 9.3.0:

-Wcast-function-type

Warn when a function pointer is cast to an incompatible function pointer. In a cast involving function types with a variable argument list only the types of initial arguments that are provided are considered. Any parameter of pointer-type matches any other pointer-type. Any benign differences in integral types are ignored, like int vs. long on ILP32 targets. Likewise type qualifiers are ignored. The function type void (*) (void) is special and matches everything, which can be used to suppress this warning. In a cast involving pointer to member types this warning warns whenever the type cast is changing the pointer to member type. This warning is enabled by -Wextra.


My suggestion: turn the warning off, at least for the file that contains this code. Code invoking a dynamic linker can't be checked in any sane way by a compiler.

--

_______________________________________________
lua-l mailing list -- lua-l@lists.lua.org
To unsubscribe send an email to lua-l-leave@lists.lua.org