[PATCH] D24238: StaticAnalyzer CastToStruct : No memory corruption when casting array to struct

Daniel Marjamäki via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 12 02:40:52 PDT 2016


danielmarjamaki added a comment.

If the -fno-strict-aliasing would fix this warning then it would be OK.

If you are telling me that this CastToStruct check is about alignment or endianness then I think the message is highly misleading. We should rewrite the message.

In general, using char instead of short/int does not prevent alignment/endianness problems as far as I see. You can still have just as many such problems even though array is char.

I am not sure why they did not use char here. But on their platform, sizeof(char)==sizeof(short)==sizeof(int)==1. It does not matter much if a typedef uses char or int.


https://reviews.llvm.org/D24238





More information about the cfe-commits mailing list