[llvm-bugs] [Bug 45707] unaligned Memory Access Identify

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Apr 28 02:17:10 PDT 2020


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

Roman Lebedev <lebedev.ri at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |INVALID
                 CC|                            |lebedev.ri at gmail.com
             Status|NEW                         |RESOLVED

--- Comment #1 from Roman Lebedev <lebedev.ri at gmail.com> ---
> void test() {
>   int *p = (int *)0x101;
>   *p = 2;
> }

That is UB.
int is 4-byte aligned.
If you've got a misaligned pointer, you need to use memcpy to access it.

-- 
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/20200428/07cd65d8/attachment.html>


More information about the llvm-bugs mailing list