[PATCH] D17746: Fix PR26741 -- __builtin_object_size is not consistently conservative with C++ inheritance

George Burgess IV via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 18 11:51:40 PDT 2016


george.burgess.iv abandoned this revision.
george.burgess.iv added a comment.

I don't feel strongly about how we should handle this, to be honest. Feeding your example into GCC 4.8 like so:

  #include <stdio.h>
  
  struct Foo { char k[1]; };
  
  struct Bar : Foo {};
  
  int __attribute__((noinline)) bos(Bar *b) {
    return __builtin_object_size(&b->k[0], 1);
  }
  
  int main() {
    Bar b;
    printf("%d\n", bos(&b));
    return 0;
  }

...The resultant executable prints "1". So, it seems that having this detection would be above and beyond what GCC offers. Given that "above and beyond," in this case implies "less likely to produce an accurate answer," I agree that this probably isn't such a great idea. :)

Thanks for the feedback!


http://reviews.llvm.org/D17746





More information about the cfe-commits mailing list