了解到这不是大量的上下文,我有这样一行:
using GridType = Grid<boost::optional<float>, 2>;
cppcheck说:
Redundant code: Found a statement that begins with numeric constant.
我会认为是"假阳性",但通常这些分析工具比我更聪明,所以我想看看是否有人能想到为什么分析器会这样解释这样的陈述?
我在Ubuntu系统上使用cppcheck 1.61。
cppcheck主要基于模式匹配,有时不太聪明/很肤浅。它确实发现了很多不错的东西,但也有很多错误。我认为这是一个错误的肯定,cppchecks简单的头脑被混淆了。
此外;1.61版本有点旧。你测试过最新的1.74吗?看看它在这里是否更聪明?(如果它不在您的发行版存储库中,那么从源代码构建非常简单)