https://bugs.llvm.org/show_bug.cgi?id=47411
Bug ID: 47411
Summary: False negative of -Winteger-overflow
Product: clang
Version: trunk
Hardware: PC
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: Frontend
Assignee: unassignedclangb...@nondot.org
Reporter: mat...@google.com
CC: llvm-bugs@lists.llvm.org, neeil...@live.com,
richard-l...@metafoo.co.uk
Repro at https://godbolt.org/z/1rorM4, code also copied below. See the
assignment of `does_not_warn`.
Compiled with default options using clang version 12.0.0
(https://github.com/llvm/llvm-project.git
96ef6998dfcc4d7f2c7fcb87eb9369e94a40e127)
===
#include <cstdint>
#include <iostream>
#include <utility>
struct HasAnInt64 {
int64_t v;
};
int64_t g(HasAnInt64 s) { return 0; }
template<typename T>
int64_t g2(T s) { return 0; }
int main() {
// Each of these raises a `-Winteger-overflow` diagnostic...
int64_t warns1 = 512 * 1024 * 1024 * 1024;
HasAnInt64 warns2{512 * 1024 * 1024 * 1024};
int64_t warns3 = g({512 * 1024 * 1024 * 1024});
int64_t warns4 = g2<HasAnInt64>({512 * 1024 * 1024 * 1024});
// ... but not this one.
auto does_not_warn = std::make_pair<int, HasAnInt64>(0, {512 * 1024 * 1024
* 1024});
// Overflow occurs. This prints `0`.
std::cout << does_not_warn.second.v << std::endl;
return 0;
}
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs