c++ - Microsoft VS2015 C++ Core Guidelines分析: "no array to pointer decay (bounds.3)" for vtable?

标签 c++ visual-studio-2015 cpp-core-guidelines

当我在我的 VS2015 项目上运行 CppCoreCheck 代码分析时,我收到许多看起来“无法修复”的警告,因为它们指的是类和 vtables 的底层 C++ 实现:

示例类:

// Header file
class IMyClass {
public:
    virtual ~IMyClass() {}
    virtual void MyMethod() = 0;
};

class MyClass : public virtual IMyClass {
public:
    MyClass();
    virtual ~MyClass();
    virtual void MyMethod() override;
};


// Impl file
MyClass::MyClass() { } // This line creates two warnings from CppCoreCheck
MyClass::~MyClass() { }
void MyClass::MyMethod() { }

还有警告:

warning C26485: Expression 'MyClass::`vbtable'': No array to pointer decay. (bounds.3: http://go.microsoft.com/fwlink/p/?LinkID=620415)
warning C26481: Don't use pointer arithmetic. Use span instead. (bounds.1: http://go.microsoft.com/fwlink/p/?LinkID=620413)

警告所提示的行引用了 MyClass 的构造函数定义

为清楚起见;我没有在代码中的任何地方直接引用 vtable;我只是以 100% 典型的方式使用虚拟继承。

有人可以确认这是否是 VS2015 实现 CppCoreCheck 时特有的错误吗?如果是,是否在 VS2017 中解决了?

最佳答案

这是 VS2015 中的一个已知问题,不会被修复。是resolved as of VS2017, v15.5 .

关于c++ - Microsoft VS2015 C++ Core Guidelines分析: "no array to pointer decay (bounds.3)" for vtable?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51843205/

相关文章:

c++ - 什么时候必须刷新 C++ 中的输出流?

c++ - SetWindowLongPtr 不能正常工作

c++ - OpenGL glGetUniformBlockIndex在nvidea GPU上返回INVALID_INDEX

c++ - 蛇算法 - opencv 事件轮廓 - 效果不佳

c++ - 在这种情况下如何防止ODR违规?

c++ - 我应该在新的 C++ 项目中使用指南支持库 (GSL) 吗?

node.js - Cordova Tools for Visual Studio 无法构建

c# - 如何将/features :strict (of csc. exe 的等价物指定给 msbuild.exe 或 .csproj 文件?

c++ - Qt - std::unordered_map - 销毁时间

c++ - 我如何使用 gsl::span 并指示所有权?