http://llvm.org/bugs/show_bug.cgi?id=11745
Bug #: 11745
Summary: incorrect class layout with duplicate empty base
classes of small nonempty class
Product: clang
Version: unspecified
Platform: PC
OS/Version: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: C++
AssignedTo: [email protected]
ReportedBy: [email protected]
CC: [email protected], [email protected]
Classification: Unclassified
Given:
template<typename T, unsigned> struct X : T {};
struct E {};
struct Test1 : X<E,0>, X<E,1>, X<E,2>, X<E,3> {};
struct Test2 : X<E,0>, X<E,1>, X<E,2>, X<E,3> { char c; };
sizeof(Test1) is 4, as expected, and the E base subobjects all have distinct
addresses. sizeof(Test2) is 1, and the second, third and fourth E base
subobjects lie outside the full-object!
In particular, this static assert fails:
Test2 a[2];
static_assert((E*)(X<E,1>*)&a[0] != (E*)(X<E,0>*)&a[1], "should not happen");
--
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs