[PATCH] D24238: StaticAnalyzer CastToStruct : No memory corruption when casting array to struct
Artem Dergachev via cfe-commits
cfe-commits at lists.llvm.org
Mon Sep 12 08:24:29 PDT 2016
NoQ added a comment.
Random thoughts:
- This checker doesn't alter the exploded graph, so it cannot be causing or suppressing positives in other checkers.
- We should not be adding platform-specific behavior (eg. working as if `sizeof(int) == 1`) without actually ensuring that it is so on that platform.
- As far as i understand, even if `sizeof(int) == 1`, casting an `int *` into a structure pointer violates the strict aliasing rule. Simply because `int` and `char` are different types, even if they have same size and signedness (note that also `char`, `signed char`, `unsigned char` are three different types, despite two of them refer to the same thing).
> In general, using char instead of short/int does not prevent alignment/endianness problems as far as I see.
You're right on this one, it'd only prevent endianness of the buffer ints from causing problems.
https://reviews.llvm.org/D24238
More information about the cfe-commits
mailing list