[PATCH] D20561: Warn when taking address of packed member

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 16 12:40:33 PDT 2016


rsmith added a comment.

I agree, that looks like correct behavior for the warning. Thanks!


================
Comment at: lib/Sema/SemaCast.cpp:259-260
@@ -258,2 +258,4 @@
         return ExprError();
+      if (DestType->isVoidPointerType())
+        DiscardMisalignedMemberAddress(E);
     }
----------------
More generally, I think we should discard it if the destination of the cast is a suitably-aligned pointer type. (For instance, casting to char* should be OK, and casting an __attribute__((packed,aligned(2))) to a 2-byte-aligned pointer type should be OK.)


http://reviews.llvm.org/D20561





More information about the cfe-commits mailing list