<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 - No -Wtautological-compare warning issued"
href="https://bugs.llvm.org/show_bug.cgi?id=37113">37113</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>No -Wtautological-compare warning issued
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>6.0
</td>
</tr>
<tr>
<th>Hardware</th>
<td>All
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</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>riyaz@synopsys.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>For the following simple test case, clang fails to issue a
-Wtautological-compare warning. gcc 6.2 issues this warning.
If there was no pointer deference (and there was a self compare on a simple
int), then clang would issue the warning as expected. The pointed memory is not
volatile and clang -O1 optimizes away the two comparisons that would always
evaluate to false. So it is reasonable to expect that it should warn about them
as well.
struct Foo {
int a;
};
int cmp(const Foo* x, const Foo* y);
int cmp(const Foo* x, const Foo* y)
{
if (x->a < x->a) {
return -1;
} else if (y->a > y->a) {
return 1;
}
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>