Rule c:S855 should not trigger when types are "promoted" to void*

Hi Sonar guys,

In C, we think that rule c:S855 (Function pointers should not be converted to any other type) should not trigger when args/return types are promoted to void *.


typedef (int) (*my_func_t) (size_t sz, const void *input, void *output);

int some_func(size_t sz, const uint8_t *input, uint8_t *output) {

my_func_t f = (my_func_t) some_func; // triggers c:S855

This kind of error happens when you have an external “framework” that expects a table of functions. Because it is generic it cannot enforce the types of input and output.

You can workaround this by keeping the void * signature in your func and performing a cast inside it, but we think it is worth skipping this rule on void * promotion.


Hi @dextermagnific,

rule c:S855 is not enabled by default and it is a MISRA rule which is quite strict, I am not sure we should relax it. You should probably consider to deactivate it from your quality profile or resolve manually the issues as “won’t fix”.