[PATCH] D32456: [ubsan] Make the alignment check work with some extern decls (PR32630)

Vedant Kumar via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 24 22:35:21 PDT 2017


vsk added a comment.

In https://reviews.llvm.org/D32456#736120, @efriedma wrote:

> > Note: it would still not be able to catch the following case --
>
> Do you know why?


As-written, the alignment check doesn't apply to loads and stores on non-pointer POD types. The reason why is probably that most of these loads/stores happen on the stack, where the data should be aligned.



================
Comment at: lib/CodeGen/CodeGenModule.cpp:2319
+      // The alignment sanitizer can catch more bugs if we don't attach
+      // alignment info to extern globals.
+    } else {
----------------
efriedma wrote:
> If we don't explicitly set the alignment, is it 1?  Or is it picking up the alignment from the type somehow?
If the alignment isn't explicitly set, it is initialized to 0. The LangRef states: 'Either global variable definitions or declarations may have an explicit section to be placed in and may have an optional explicit alignment specified'. It should be OK to not specify the alignment.


https://reviews.llvm.org/D32456





More information about the cfe-commits mailing list