什么是叮当检查的垃圾值
What's a garbage value for clang-check
我收到以下警告:
test.cpp:14:25: warning: The right operand of '/' is a garbage value
return (std::abs(a) / size) > 10;
^ ~~~~
对于这段代码:
#include <algorithm>
#include <complex>
#include <vector>
#include <iostream>
using namespace std;
double
pitchDetect(const std::vector<std::complex<double>> &dft,
unsigned int samplingRate) noexcept {
if (dft.empty())
return 0.0;
auto it = find_if(begin(dft), end(dft),
[size = dft.size()](const std::complex<double> &a) {
return (std::abs(a) / size) > 10;
});
return 0.0;
}
我不明白问题出在哪里!
这看起来像是在trunk:中修复的bug 22833
给lambda捕获参数一个显式值(C++14中的新特性)会导致分析器认为该值是未定义的。
作为一种变通方法,您可以尝试将init捕获提升到lambda:之外
auto const size = dft.size();
auto it = find_if(begin(dft), end(dft),
[size](const std::complex<double> &a) {
return (std::abs(a) / size) > 10;
});
相关文章:
- valgrind-hellgrind与泄漏检查的结果不同
- C++模板来检查友元函数的存在
- 检查输入是否不是整数或数字
- 试图让变量检查数组中的某些内容
- 检查值是否在集合p1和p2中,但不在p3中
- C++概念:如何使用'concept'检查模板化结构的属性?
- 概念TS检查忽略私有访问修饰符
- 检查 std::shared_ptr<> 的当前底层类型是否为 T
- 在c++中检查长方体是否尽可能快地重叠(无迭代)
- 如何在C++中检查2D数组中负值的输入验证
- 叮当不知道PTRDIFF_MAX?
- C++:正在检查LinkedList中的回文-递归方法-错误
- 使用for循环检查数组中的重复项
- MacOS通过在莫哈韦"wchar.h"下破碎的自制啤酒发出叮当声
- 如何检查一个c++字符串中有多少相同的字符/数字
- 检查不带转换的扫描格式
- 如何检查线程是否锁定
- 清除前检查矢量
- 如何处理来自核心指南检查器的关于gsl::at的静态分析警告
- 什么是叮当检查的垃圾值