On
2019-06-22 20:59:57 +0200, Michael Matz wrote:
Indeed. The thing is that such "mis"-alignment isn't generically undefined
behaviour (and hence shouldn't even be part of -fsanitize=undefined). It's
implementation defined what it means for a pointer to an object type to be
correctly aligned (e.g. one where the natural alignment of all types is 1 is
fully conforming). Accessing something via an incorrectly aligned pointer
is undefined, but what incorrectly aligned means is implementation defined.
Yes,
it's implementation defined, but I assume that -fsanitize=undefined
warns
only when the implementation has decided that this was incorrectly
aligned.
Probably everyone has already seen this blog post about GCC generating code that crashes if pointers to uint32_t are not aligned to 4, but I will post the URL just in case:
|