[PATCH] D21453: Add support for attribute "overallocated"

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 16 17:23:22 PDT 2016


rsmith added inline comments.

================
Comment at: include/clang/Basic/AttrDocs.td:2073-2079
@@ +2072,9 @@
+  let Content = [{
+Use ``overallocated`` to indicate a struct or union is over-allocated. For example,
+
+.. code-block:: c++
+
+struct S {
+  char a[4], char b[4];
+} __attribute__((overallocated));
+
----------------
I don't think this says what you mean. "Overallocated" alone does not imply that you can use S::b to access more than 4 bytes. If you want that to work, I think the right model is for the attribute to imply that the final member within the struct is treated as a flexible array member, no matter what its array bound is.

This should then apply to everywhere we consider flexible array members, not just to builtin_object_size.


http://reviews.llvm.org/D21453





More information about the cfe-commits mailing list