MISRA Discussion Forums
5-2-7 and void pointer conversions - Printable Version

+- MISRA Discussion Forums (https://forum.misra.org.uk)
+-- Forum: MISRA C++ (https://forum.misra.org.uk/forumdisplay.php?fid=18)
+--- Forum: MISRA C++:2008 rules (https://forum.misra.org.uk/forumdisplay.php?fid=19)
+---- Forum: 6.5 Expressions (C++) (https://forum.misra.org.uk/forumdisplay.php?fid=134)
+---- Thread: 5-2-7 and void pointer conversions (/showthread.php?tid=1437)



5-2-7 and void pointer conversions - rgamble - 13-07-2018

Are conversions between pointers to void and pointers to object types a violation of rule 5-2-7? It isn't clear what "object with pointer type" means here (or "unrelated pointer type" for that matter). Specifically, are either of the casts below a violation of Rule 5-2-7?

Code:
void bar(int *ip, void *vp) {
    ip = static_cast(vp);
    vp = static_cast(ip);
}



Re: 5-2-7 and void pointer conversions - misra cpp - 17-07-2018

It was not intended that 5-2-7 should address the use of void* - though we recognise that this could be more clearly expressed, and will be clarified in the next issue

5-2-8 bans casts from void* to other pointer types, but casting a pointer type to void* is permitted