Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
5-2-7 and void pointer conversions
#1
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);
}
<t></t>
Reply
#2
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
Posted by and on behalf of
the MISRA C++ Working Group
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)