I need a static analyzer that will find uninitialized variables members/variables... of a templated class type.
Can any analyzer do this? I tried clang/cppcheck and a couple of others with no luck.
Here is my test code:
enum class ViewMode
{
 One   = 1,
 Two     = 2,
 Three  = 3,
 Four     = 4
};
class TestClass {
 public:
   TestClass() {}
};
template<typename T, bool C = std::is_copy_constructible<T>::value>
class TemplateTest
{
 public:
  TemplateTest() {}
  TemplateTest(const T& value)
   : value_(value)
  {}
  TemplateTest(const TemplateTest&) = delete;
  TemplateTest(TemplateTest<T, C>&& rhs)
      : value_(std::move(rhs.value_))
  {}
  TemplateTest(T&& value)
      : value_(std::move(value))
  {}
 private:
  T value_;
};
class StaticAnalysisTest {
 public:
  StaticAnalysisTest() {}
  void DoSomething() {
  }
 private:
  ViewMode viewMode_;     //this uninitialized warning is found
  TemplateTest<ViewMode> viewMode2_; //this one is not
};
I have further distilled the problem to:
class Foo
{
 private:
  int m_nValue;
 public:
  Foo() {};
  Foo(int value) : m_nValue(value) {}
  int GetValue() { return m_nValue; }
};
class Bar
{
 public:
  Bar(){}
  void DoSomething() {
    Foo foo;
  }
};
This does not generate an unitialized variable warning, but when I comment out:
 //Foo(int value) : m_nValue(value) {}
it does
 
    