[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 02:25:17 PDT 2021


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

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

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

--- Comment #2 from Gonzalo BG <gonzalo.gadeschi at gmail.com> ---
I hope this makes it clearer. The above example is equivalent to:

char h(char* ptr) { 
    ptr = (char*)(int*)ptr;
    return *ptr;
}

> A pointer to an integer is 4-byte aligned:

A load through a pointer to an integer can assume 4-byte alignment.

In the functions f, g, and h that I've shown, there are no such loads anywhere.

h loads through a char*, and f loads through an unsigned char* inside
std::memcpy according to the memcpy spec.

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


More information about the llvm-bugs mailing list