c++ klocwork scan std::vector 未初始化

c++ klocwork scan std::vector uninitialized

 > -Severity (Error)
 > -ID(local): 7
 > -Code: UNINIT.CTOR.MUST --> IpuCCAInterfaceBase()
 > -Message: 'this->_remaining_run_kernels_uuids' is not initialized
 > in this constructor.
 > -Details:
 > 
 > 'this->_remaining_run_kernels_uuids' is not initialized in this
 > constructor.
 > 
 > * IpuCCAInterfaceBase.cpp:47: passing 'this' to 'InitializeSaResults'
 > does not initialize 'this->_remaining_run_kernels_uuids'
 > 
 > * IpuCCAInterfaceBase.cpp:47: passing 'this' to 'CreateNVMData'
 > does not initialize 'this->_remaining_run_kernels_uuids'
 > 
 > * IpuCCAInterfaceBase.cpp:143: 'this->_remaining_run_kernels_uuids'
 > is used, but is uninitialized.
 > 
 > Current status 'Analyze'

这是我遇到的错误

class COMMON_CCA_INTERFACE IpuCCAInterfaceBase : public ICCAOperations
{
private:

    vector<int> _remaining_run_kernels_uuids;
}

这是头文件

cpp 负责人

IpuCCAInterfaceBase::IpuCCAInterfaceBase()
{
   
}

我们正在使用 klocworks 20.1 解决此错误的推荐方法是什么?

向量稍后将在不同的函数中初始化和填充。但是当加载 class 时里面没有数据。

也许 Klockwork 要求您显式初始化向量,例如在构造函数初始化列表中:

IpuCCAInterfaceBase::IpuCCAInterfaceBase()
    : _remaining_run_kernels_uuids{ }
{
}

话虽如此,我认为该消息是误报,因为即使没有这个,向量也应该隐式默认构造(并因此初始化)。