<html>
<head>
<base href="http://llvm.org/bugs/" />
</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 --- - Warn user about comparision of reference to nullptr"
href="http://llvm.org/bugs/show_bug.cgi?id=19899">19899</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Warn user about comparision of reference to nullptr
</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>Linux
</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>ofv@wanadoo.es
</td>
</tr>
<tr>
<th>CC</th>
<td>llvmbugs@cs.uiuc.edu
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>In <a href="http://llvm.org/viewvc/llvm-project?rev=209723&view=rev">http://llvm.org/viewvc/llvm-project?rev=209723&view=rev</a> an optimization was
introduced for reducing the following case of undefined behavior:
bool foo(int &x) { return &x == 0; }
to:
bool foo(int &x) { return false; }
I noticed this new optimization because some code started crashing. AFAIK
neither of gcc, MSVC, Intel C++ apply this optimization. All of them behave on
the same way when the function is invoked as
foo((int*)nullptr);
It is reasonable to expect more instances of this problem. A behavior that
previously was undefined (by the book) but fairly predictable (by how the
available implementations work) now effectively becomes undefined.
I propose to implement a warning (active by default) for communicating the user
about the occuerrences of that type of code.
A toggle for disabling the optimization would also be a good thing as a quick
fix for those on a hurry.</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>