MISRA Discussion Forums
Rule 5-0-19 are references also considered a 'pointer indirection'? - 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: Rule 5-0-19 are references also considered a 'pointer indirection'? (/showthread.php?tid=1275)



Rule 5-0-19 are references also considered a 'pointer indirection'? - grunwald - 23-09-2016

More concretely, is the following code a violation?

Code:
typedef void **my_t;

void f(my_t& x)
{
   x = NULL;
}



Re: Rule 5-0-19 are references also considered a 'pointer indirection'? - misra cpp - 31-10-2016

References are not a level of indirection.

The rule is trying to limit the complexity when accessing / understanding multiple levels of pointers - a reference simply creates an alias for an object and does not add any further levels of indirection