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.FUNC.SPEC.OVRLD

Viable function set for a function call contains an overloaded template and its explicit specialization.

MISRA-C++ Rule 14-8-1 (required): Overloaded function templates shall not be explicitly specialized.

Rationale

Explicit specializations will be considered only after overload resolution has chosen a best match from the set of primary function templates. This may be inconsistent with developer expectations.

Example

template <typename T> void f ( T );   // overload Example 1
template <typename T> void f ( T* );  // overload Example 2

template <> void f<int32_t*> ( int32_t* ); // explicit specialization of
                                           // Example 1
void b ( int32_t * i )
{
   f ( i );              // Non-compliant
                         // - Calls Example 2, f<int32_t*>
}

Where a template is not overloaded with other templates, or is overloaded with non-template functions then it can be explicitly specialized, as it is consistent with developer expectation that the explicit specializations will only be considered if that primary template is chosen.

template <typename T> void f ( T );          // Example 1
template <> void f<int32_t*> ( int32_t* );   // Example 2

void b ( int32_t * i )
{
   f ( i );                // Compliant
                           // - Calls Example 2, f<int32_t*>
}