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

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Sun Mar 20 17:45:18 PDT 2016


On Sun, Mar 20, 2016 at 6:25 AM, Joerg Sonnenberger via cfe-commits
<cfe-commits at lists.llvm.org> wrote:
> On Fri, Mar 18, 2016 at 05:11:19PM +0000, Richard Smith via cfe-commits wrote:
>> rsmith added a comment.
>>
>> Can you explain a bit more about the problem? It seems to me that if I have:
>>
>>   struct Base {
>>     char k[1];
>>   };
>>   struct Derived : Base {};
>>
>> ... then the 'k' subobject of a `Derived` object is known to be exactly 1 byte long -- it doesn't seem obviously appropriate for our flexible-sized trailing array support to cover this case.
>
> I don't think we special case C++ for the "[1] means flexible trailing
> array" check?

No. But while we do look through the last field's type when checking
for a flexible array member, we don't look through any base classes
(which is obviously a C++-specific situation). Our behavior here seems
consistent with that (and with GCC's).


More information about the cfe-commits mailing list