consistency - conventional
Why is this an issue?
Taking the address of an object of incomplete type, where the complete type contains a user declared
operator & leads to undefined
Noncompliant code example
A * operator & ( ); // Noncompliant
void f ( A & a )
&a; // uses built-in operator &
void f2 ( A & a )
&a; // use user-defined operator &
- MISRA C++ 2008, 5-3-3 - The unary & operator shall not be overloaded.
- C++ Core Guidelines C.166 - Overload
& only as part of a system of smart pointers and references