[LLVMbugs] [Bug 19899] New: Warn user about comparision of reference to nullptr
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Fri May 30 12:41:09 PDT 2014
http://llvm.org/bugs/show_bug.cgi?id=19899
Bug ID: 19899
Summary: Warn user about comparision of reference to nullptr
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: Frontend
Assignee: unassignedclangbugs at nondot.org
Reporter: ofv at wanadoo.es
CC: llvmbugs at cs.uiuc.edu
Classification: Unclassified
In http://llvm.org/viewvc/llvm-project?rev=209723&view=rev 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.
--
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/20140530/b2b74375/attachment.html>
More information about the llvm-bugs
mailing list