[clang] -fsanitize=alignment: check memcpy/memmove arguments (PR #67766)

Fangrui Song via cfe-commits cfe-commits at lists.llvm.org
Sun Oct 8 10:16:58 PDT 2023


MaskRay wrote:

> @zygoloid Thanks for the explanation! I wasn't aware this fell under unspecified behavior. It's weird that alignment information can survive a `void *` cast, but it does make some sense.

Yes, `(void *)x` decreases the alignment requirement to 1 byte like `(char *)x`.

> What seems worrying here is that apparently GCC and Clang do not agree on semantics in this case ([godbolt.org/z/1r9df5a4a](https://godbolt.org/z/1r9df5a4a)). GCC does not assume that the pointers are aligned. The perils of unspecified behavior....

Yes...

I am out of town and will merge this PR later.

https://github.com/llvm/llvm-project/pull/67766


More information about the cfe-commits mailing list