[llvm-bugs] [Bug 47411] New: False negative of -Winteger-overflow
via llvm-bugs
llvm-bugs at lists.llvm.org
Thu Sep 3 11:04:06 PDT 2020
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: unassignedclangbugs at nondot.org
Reporter: mattdr at google.com
CC: llvm-bugs at lists.llvm.org, neeilans at live.com,
richard-llvm at 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200903/330507b4/attachment-0001.html>
More information about the llvm-bugs
mailing list