-
Type:
Code Smell Detection
-
Status: Active
-
Resolution: Unresolved
-
Labels:
-
Message:"xxx" is never instantiated. It should be removed or referenced at least once.
-
Default Severity:Minor
-
Impact:Low
-
Likelihood:Low
-
Targeted languages:C++
-
Remediation Function:Constant/Issue
-
Constant Cost:10min
-
MISRA C++ 2008:14-7-1
Similar to uncalled functions, un-instantiated class and function templates are a potential source of noise and they may be symptomatic of a more serious problem such as missing paths.
Note: Even though a given class template may be instantiated many times, it is possible that some of its member functions are never instantiated.
Noncompliant Code Example
template < typename T > class Sample { public: void inst_mem ( ) { } void uninst_mem ( ) { } // Noncompliant, never instantiated }; Sample<int64_t> s; s.inst_mem ( ); // Call to s.inst_mem instantiates the member. // s.uninst_mem is not called within the program and is not instantiated.
Exceptions
This rule does not apply to libraries.
See
- MISRA C++:2008, 14-7-1
- is related to
-
RSPEC-1763 All code should be reachable
- Active