Menu

cppcheck becomes blind when there is explicit template instantiation in the code

2017-11-01
2018-05-08
  • Alexey Popov

    Alexey Popov - 2017-11-01
    class TestClass
    {
    public:
     std::string m_strText;
    }; 
    
    template class TemplateClass < TemplateClassItem >;
    
    int main()
    {
       TestClass objTest;
       memset( &objTest , 0 , sizeof(TestClass));
    }
    

    When template row is commented then cppcheck finds the issue:

    "C:\Program Files\Cppcheck\cppcheck.exe" --enable=style main.cpp
    Checking main.cpp ...
    [main.cpp:12]: (error) Using 'memset' on class that contains a 'std::string'.

    When template is uncommented - it is blind.

     
  • versat

    versat - 2018-05-08

    It did not work until Cppcheck 1.83 but it works with the current development code. Not sure which change/fix exactly made this working now.
    So i would suggest to verify that it still works with 1.84 when it is released.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.