[llvm-bugs] [Bug 36610] clang can miscompile code involving uninitialized value and xor-s

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Mar 6 14:56:36 PST 2018


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

Andriy Gapon <avg at FreeBSD.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|INVALID                     |---

--- Comment #8 from Andriy Gapon <avg at FreeBSD.org> ---
Also, a counter-example or, rather, an example of Clang being inconsistent:
uint32_t
combine(uint16_t x, uint16_t y)
{
        uint32_t r;

        r &= 0xffff0000u;
        r |= x;
        r &= 0x0000ffffu;
        r |= (uint32_t)y << 16;

        return (r);
}

This code is compiled correctly.
In this statement
r = r & 0xffff0000u;
there is an access to unspecified value, so Clang was free to deem it the
undefined behavior, which it didn't.
I do not see any dramatic difference from the code using xor.

So, I still think that Clang has a problem reasoning about xor.

-- 
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/20180306/34cb644b/attachment.html>


More information about the llvm-bugs mailing list