This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Fix undefined behavior due to misaligned type cast
ClosedPublic

Authored by jkorous-apple on Mar 16 2018, 12:39 PM.

Details

Summary

The current code is casting pointer to a misaligned type which is undefined behavior.

Found by compiling with Undefined Behavior Sanitizer and running tests (check-clang-tools).

AFAIK clang produces the same code for reinterpret_cast<>() and memcpy().

Follow-up to: https://reviews.llvm.org/D44575

Diff Detail

Event Timeline

jkorous-apple created this revision.Mar 16 2018, 12:39 PM
JDevlieghere accepted this revision.Mar 19 2018, 3:32 AM
This revision is now accepted and ready to land.Mar 19 2018, 3:32 AM
ilya-biryukov accepted this revision.Mar 19 2018, 6:29 AM

I commited the patch but forgot to quote this review.

git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@327902 91177308-0d34-0410-b5e6-96231b3b80d8