cpp:S5356 void* as unrelated type

Hello @JonPovirk,

I agree that casting to void* is not per se a problem, from the language point of view. However, this rule is linked to the MISRA C++2008 specification, which explicitly says:

Note: An object with pointer to void type is not a related type and therefore conversions to such a type are not permitted.

I think you have 3 options here:

  • Strictly follow MISRA C+2008 by activating cpp:S5356 (and deviate from the rule when you really need it)
  • Instead, activate cpp:S856, which is less strict, and was specifically written to allow such cases
  • Long term option: wait for new MISRA version, which is planned to be less strict in that case (I cannot provide more details for now).
2 Likes