[英]What is gcc -Wstringop-overflow complaining about here?
The following code (reduced from a larger, more sensible sample):以下代码(从更大、更合理的示例中缩减而来):
#include <vector>
void shrink(std::vector<int>& v) {
while (v.size() > 0) {
v.resize(v.size() - 1);
}
}
Leads gcc 7.3 to emit this warning ( godbolt ):导致 gcc 7.3 发出此警告( Godbolt ):
In function 'void shrink(std::vector<int>&)':
cc1plus: warning: 'void* __builtin_memset(void*, int, long unsigned int)':
specified size 18446744073709551612 exceeds maximum object size 9223372036854775807 [-Wstringop-overflow=]
I have been staring at this code for close to an hour with a colleague, and it just seems correct to me;我和一位同事一起盯着这段代码看了将近一个小时,对我来说这似乎是正确的; what is gcc complaining about? gcc 在抱怨什么?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.