Start here

Home
About Klocwork
What's new
Fixed issues
Release notes
Installation

Reference

C/C++ checkers
Java checkers
C# checkers
MISRA C 2004 checkers
MISRA C++ 2008 checkers
MISRA C 2012 checkers
MISRA C 2012 checkers with Amendment 1
Commands
Metrics
Troubleshooting
Reference

Product components

C/C++ Integration build analysis
Java Integration build analysis
Desktop analysis
Refactoring
Klocwork Static Code Analysis
Klocwork Code Review
Structure101
Tuning
Custom checkers

Coding environments

Visual Studio
Eclipse for C/C++
Eclipse for Java
IntelliJ IDEA
Other

Administration

Project configuration
Build configuration
Administration
Analysis performance
Server performance
Security/permissions
Licensing
Klocwork Static Code Analysis Web API
Klocwork Code Review Web API

Community

View help online
Visit RogueWave.com
Klocwork Support
Rogue Wave Videos

Legal

Legal information

MISRA.BASE.IDS.UNIQUE

Member name is used twice in inheritance hierarchy.

MISRA-C++ Rule 10-2-1 (advisory): All accessible entity names within a multiple inheritance hierarchy should be unique.

Rationale

If the names are ambiguous, the compiler should report the name clash and not generate arbitrary or unexpectedly resolved code. However, this ambiguity may not be obvious to a developer. There is also a specific concern that if the member function is virtual, resolving the ambiguity by explicitly referencing the base class in effect removes the virtual behaviour from the function.

Exception

For the purposes of this rule, visible function identifiers that form an overload set shall be considered as the same entity.

Example

class B1
{
public:
   int32_t count; // Non-compliant
   void foo ( ); // Non-compliant
};
class B2
{
public:
   int32_t count; // Non-compliant
   void foo ( ); // Non-compliant
};
class D : public B1, public B2
{
public:
   void Bar ( )
   {
      ++count; // Is that B1::count or B2::count?
      foo ( ); // Is that B1::foo() or B2::foo()?
   }
};

In the above example, in a member function of D, the use of count or foo is ambiguous and must be disambiguated by B1::count, B2::foo, etc.