Uploaded image for project: 'Rules Repository'
  1. Rules Repository
  2. RSPEC-1029

Class templates, function templates, class template member functions and class template static members should be instantiated at least once

    Details

    • 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

      Description

      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

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                Anonymous
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated: