<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - False negative of -Winteger-overflow"
href="https://bugs.llvm.org/show_bug.cgi?id=47411">47411</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>False negative of -Winteger-overflow
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Frontend
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>mattdr@google.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
</td>
</tr></table>
<p>
<div>
<pre>Repro at <a href="https://godbolt.org/z/1rorM4">https://godbolt.org/z/1rorM4</a>, code also copied below. See the
assignment of `does_not_warn`.
Compiled with default options using clang version 12.0.0
(<a href="https://github.com/llvm/llvm-project.git">https://github.com/llvm/llvm-project.git</a>
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;
}</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>