facil.io icon indicating copy to clipboard operation
facil.io copied to clipboard

Make test run by default, avoid *void function cast error

Open janbiedermann opened this issue 3 years ago • 3 comments

janbiedermann avatar Jul 06 '21 20:07 janbiedermann

I like that we can avoid the warning... but... do we really want to avoid the warning?

Wouldn't it be better to have explicit code (i.e. (void*)(intptr_t)(func)) rather than miss instances where this comment actually reveals an unintended cast?

I think finding any warnings in the code would be better 🤔?

boazsegev avatar Jul 07 '21 16:07 boazsegev

Nono, its not avaoiding the warning, its avoiding the error. The error makes compilation stop. I guess this is since gcc 9 or so with -pedantic, having these casts is a problem. There is no simple solution, even casting will print a warning/error so this just makes it print the warning and compilation succeed. It really needs another solution, like VAARGS or args with the relevant types.

janbiedermann avatar Jul 07 '21 22:07 janbiedermann

I think I will need to test alternatives before I disable a warning that might actually indicate an unintended error.

I was pretty sure an explicit "chain" casting using uintptr_t can be used to prevent these types of warnings by informing the compiler that this cast is intentional (i.e., (int (*)(int)(intptr_t)fn)... but maybe I missed something.

boazsegev avatar Jul 12 '21 20:07 boazsegev