MISRAC++2008-14-6-1 (C++ only)
In this section:
Synopsis
(Required) In a class template with a dependent base, any name that may be found in that dependent base shall be referred to using a qualified-id or this->.
Enabled by default
Yes
Severity/Certainty
Medium/Medium

Full description
Found a dependent bae name without qualified lookup. This check is identical to MISRAC++2023-6.4.3.
Note: This check is not part of C-STAT® but detected by the IAR compiler.
Coding standards
- MISRA C++ 2023 6.4.3
(Required) A name that is present in a dependent base shall not be resolved by unqualified lookup
Code examples
The following code example fails the check and will give a warning:
#include <vector>
using value_type = unsigned char;
template< typename T >
class buff : public T
{
// Non-compliant for vec<std::vector> - compiler will choose ::value_type
// If vec inherited directly from std::vector, std::vector::value_type
// would have been chosen
value_type eot;
};
buff< std::vector<int> > v;
The following code example passes the check and will not give a warning about this issue:
#include <vector>
using value_type = unsigned char;
template< typename T >
class buff : public T
{
::value_type eot;
};
buff< std::vector<int> > v;