[llvm-bugs] [Bug 40402] using optimizations yields different output

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Jan 22 11:03:35 PST 2019


https://bugs.llvm.org/show_bug.cgi?id=40402

Tim Northover <t.p.northover at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |INVALID
                 CC|                            |t.p.northover at gmail.com

--- Comment #1 from Tim Northover <t.p.northover at gmail.com> ---
C and C++ don't allow you to shift an n-bit number by exacltly n places (or
more). It's classified as "undefined behaviour" and compilers will assume it
doesn't happen when optimizing code.

The algorithm in the attached file flags up multiple cases of this when
compiled with -fsanitize=undefined, so there's a very good chance that's the
issue.

If you haven't encountered undefined behaviour before, Chris Lattner wrote a
good blog series on it, and how it affects C compilers, a few years ago:
http://blog.llvm.org/2011/05/what-every-c-programmer-should-know.html.

Let us know if you can reproduce the issue after fixing t.c, but for now I'll
close this.

-- 
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/20190122/625a63db/attachment.html>


More information about the llvm-bugs mailing list