[PATCH] Sema CXX: sometimes allow inheritance from class with flexible array

David Majnemer david.majnemer at gmail.com
Fri Feb 21 23:37:27 PST 2014


Hello,

This patch isn't quite right, consider the following:

struct BaseWithFlexible { int a[]; };
struct NotSoEmptyBase { int b; };
struct Derived : BaseWithFlexible, NotSoEmptyBase { };

In this example, 'Derived' has no fields but the flexible array member
still interferes with 'NotSoEmptyBase'

another test case:
struct BaseWithFlexible { int a[]; };
struct Derived : virtual BaseWithFlexible { };

In this case, the flexible array member would index into the
v-table/vb-table pointer of 'Derived'.

final test case:
struct BaseWithFlexible { int a[]; };
struct Derived : BaseWithFlexible { virtual ~Derived() {} };

For this final case, the flexible array member would index into the
v-table/vf-table of 'Derived'.

-- 
David Majnemer

On Fri Feb 21 2014 at 10:47:39 PM, Curtis Dunham <curtis.dunham at gmail.com>
wrote:

Hi all,
Please consider for review this patch.

If a class deriving from an base class with a flexible array has no new
data members of its own, the issue of the data member offset never comes
into play.  I have a large, mature codebase that tripped over this recently
added, but slightly overzealous, semantic check.

thanks,
Curtis Dunham
_______________________________________________
cfe-commits mailing list
cfe-commits at cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140222/58a8afba/attachment.html>


More information about the cfe-commits mailing list