为什么 CPP 检查不显示任何错误
Why is CPP Check not showing any ERRORS?
This
cppcheck --enable=style --inconclusive --check-config --xml --xml-version=2 -v -I.. -I../mocks -I../gmock -I../gtest -DUNIT_TEST ../src
结果是这个
<?xml version="1.0" encoding="UTF-8"?>
<results version="2">
<cppcheck version="1.52"/>
<errors>
Checking ../src/AppMain.cpp...
</errors>
</results>
显然,我做错了什么——但是呢?
顺便说一句,我确定代码有问题,但可以肯定的是,我将这两行粘贴到其中
char a[10];
a[10] = 0;
并且没有关于越界引用的报告
如果没有一个最小的工作示例来重现问题,就很难提供帮助。
首先,删除 check-config 参数,因为它执行以下操作:
--检查配置检查 cpppcheck 配置。普通代码此标志禁用分析。
如果您定义了UNIT_TEST并且此特定代码段因此未处于活动状态,则不会显示任何问题。
此外,如果要查看错误,则应指定"--enable=all",因为越界被归类为错误,而不是样式。未使用的变量(如您的示例中给出的(是一个样式问题。
运行 cppcheck (v1.72(
cppcheck --enable=all --inconclusive --xml-version=2 -v foo.cpp
关于这个
void main()
{
char a[10];
a[10] = 0;
}
为我产生以下输出
<?xml version="1.0" encoding="UTF-8"?>
<results version="2">
<cppcheck version="1.72"/>
<errors>
<error id="unreadVariable" severity="style" msg="Variable 'a' is assigned a value that is never used." verbose="Variable 'a' is assigned a value that is never used.">
<location file="foo.cpp" line="5"/>
</error>
<error id="arrayIndexOutOfBounds" severity="error" msg="Array 'a[10]' accessed at index 10, which is out of bounds." verbose="Array 'a[10]' accessed at index 10, which is out of bounds.">
<location file="foo.cpp" line="5"/>
</error>
</errors>
</results>
相关文章:
- 类和构造函数中的函数根本不起作用,并且不返回任何错误
- boost::p rogram_options 在指定意外的位置参数时不报告任何错误
- Antlr cpp 运行时 任何错误的指针转换?
- 我可以使用 try catch 语句来捕获任何错误而不是具体错误吗?
- 为什么 C++ 中的分号在插入代码开头时不显示任何错误?
- 如何修复任何错误
- 为什么<<低;和 cout<<v.begin;单独给出错误,但 cout <<(lower.begin());没有给出任何错误,并使代码易于编译
- 我是否需要处理以下代码中的任何错误情况?
- 我的代码在构建时没有任何错误,但无法正常工作
- 由于错误,c ++代码无法在Visual Studios上运行,但不显示任何错误
- ROS2 COLCON构建未在Windows中显示任何错误消息
- 如何调试 gRPC 服务器崩溃而没有任何错误
- 尝试使用类,但未打印任何内容.不会生成任何错误.我错过了什么吗?
- 代码没有任何错误,但什么也不在命令提示中
- GTK图像突然不会刷新任何错误或警告
- STL 中是否有任何错误代码异常
- 用“ strcpy”在2D数组中删除(字符)的一行(字符)时是否存在任何错误
- Oracle ODBC 插入失败,没有任何错误诊断
- 检查输入的文件是否有任何错误
- 带有绝对路径的LoadLibrary返回不正确的HMODULE,没有任何错误