Rule 5-0-19 are references also considered a 'pointer indirection'?

Moderators: david ward, misra cpp

Post Reply
grunwald
Posts: 12
Joined: Wed May 14, 2014 1:02 pm
Company: Axivion GmbH

Rule 5-0-19 are references also considered a 'pointer indirection'?

Post by grunwald » Fri Sep 23, 2016 4:45 pm

More concretely, is the following code a violation?

Code: Select all

typedef void **my_t;

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

misra cpp
Posts: 148
Joined: Mon Jun 02, 2008 1:55 pm
Company: MISRA

Re: Rule 5-0-19 are references also considered a 'pointer indirection'?

Post by misra cpp » Mon Oct 31, 2016 3:16 pm

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
Posted by and on behalf of
the MISRA C++ Working Group

Post Reply

Return to “6.5 Expressions (C++)”