c – clang-check的垃圾值是多少
发布时间:2020-12-16 07:14:32 所属栏目:百科 来源:网络整理
导读:我收到了以下警告: 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 iostreamusing namespace std;doublepitch
|
我收到了以下警告:
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;
}
我不明白是什么问题! 解决方法
这看起来像
bug 22833,固定在trunk中:
作为一种解决方法,您可以尝试在lambda外部提升init-capture: auto const size = dft.size();
auto it = find_if(begin(dft),[size](const std::complex<double> &a) {
return (std::abs(a) / size) > 10;
});
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
