[llvm-bugs] [Bug 49708] std::memcpy with incorrect align attribute on arguments introduces undefined behavior

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Mar 24 03:13:06 PDT 2021


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

Gonzalo BG <gonzalo.gadeschi at gmail.com> changed:

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

--- Comment #5 from Gonzalo BG <gonzalo.gadeschi at gmail.com> ---
https://eel.is/c++draft/expr.static.cast#13 states 

>If the original pointer value represents the address A of a byte in memory and A does not satisfy the alignment requirement of T, then the resulting pointer value is unspecified.

So the behavior of `(int*)char_ptr` is unspecified, since that's equivalent to
`static_cast<int*>(static_cast<void*>(char_ptr))` and char_ptr does not satisfy
the alignment requirement of `int`.

Closing as non-bug. Thanks.

-- 
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/20210324/35a8a01f/attachment.html>


More information about the llvm-bugs mailing list