[PATCH] D12000: Bugfix - Clang handles __builtin_object_size in wrong way

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 17 13:11:01 PDT 2015


rsmith accepted this revision.
rsmith added a reviewer: rsmith.
rsmith added a comment.
This revision is now accepted and ready to land.

LGTM with one more testcase :)


================
Comment at: lib/AST/ExprConstant.cpp:6243-6245
@@ +6242,5 @@
+  } else if (End.Designator.IsOnePastTheEnd) {
+    // We're already pointing at the end of the object.
+    AmountToAdd = 0;
+  }
+
----------------
rsmith wrote:
> Please add testcases for the pointer-to-the-end case:
> 
>   int n;
>   static_assert(__builtin_object_size(&n + 1, 1) == 0);
> 
>   struct X { int a, b, c; } x;
>   static_assert(__builtin_object_size(&x.a + 1, 1) == 0);
> 
I think you now have a testcase for the end-of-array case, but not the end-of-nonarray case.


http://reviews.llvm.org/D12000





More information about the cfe-commits mailing list