[LLVMbugs] [Bug 18095] clang 3.3 and more recent miscompiles NULL pointer arithmetic in optimized builds (O2)

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri Nov 29 07:58:11 PST 2013


http://llvm.org/bugs/show_bug.cgi?id=18095

jonathan.sauer at gmx.de changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |jonathan.sauer at gmx.de
         Resolution|---                         |INVALID

--- Comment #2 from jonathan.sauer at gmx.de ---
As you said, this is undefined behavior (as the NULL pointer does not point to
the element of an array object, cf. C99 6.5.6p8), so the compiler can do
whatever it wants -- which includes assuming that the pointer will never be
NULL.

There is a nice series of blog posts on the LLVM blog that goes into some
detail on how compilers exploit undefined behavior for optimization:
<http://blog.llvm.org/2011/05/what-every-c-programmer-should-know.html>

Another paper on the subject is "Undefined Behavior: What Happened to My
Code?": <http://people.csail.mit.edu/akcheung/papers/apsys12.html>

-- 
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/20131129/e5ddfbce/attachment.html>


More information about the llvm-bugs mailing list