[llvm-bugs] [Bug 47793] Miscompilation of single loop with two assignments

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Oct 11 10:02:14 PDT 2020


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

Florian Hahn <florian_hahn at apple.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |INVALID
             Status|NEW                         |RESOLVED
                 CC|                            |florian_hahn at apple.com

--- Comment #3 from Florian Hahn <florian_hahn at apple.com> ---
(In reply to Tuom Larsen from comment #2)
> Sorry, I'm new to all this. Could you please point me to where you see the
> undefined behaviour? I'm just copying bunch of uint16_t's. Even if I could
> use memcpy, who knows what memcpy would in fact do and this is what broke(?).

The problem is likely that you are accessing the same memory through uint16_t
and uint64_t pointers. Clang assumes 'strict aliasing' by default IIRC and
under those rules I think that is not allowed. See
http://dbp-consulting.com/tutorials/StrictAliasing.html for an explanation.

Please try your example with -fno-strict-aliasing. Your code should work as
expected with that option. If not, please re-open the issue.

-- 
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/20201011/aebecb46/attachment.html>


More information about the llvm-bugs mailing list