Tail pad optimization, cache friendlyness and C++ interrop

deadalnix via Digitalmars-d digitalmars-d at puremagic.com
Tue Jun 10 23:09:50 PDT 2014


On Wednesday, 11 June 2014 at 03:19:55 UTC, Walter Bright wrote:
> On 6/10/2014 7:44 PM, deadalnix wrote:
>> On Wednesday, 11 June 2014 at 02:10:18 UTC, Walter Bright 
>> wrote:
>>> On 6/10/2014 5:27 PM, deadalnix wrote:
>>>> I'm talking about structs, not classes.
>>>
>>> Ok, but since D structs do not inherit, how does tail pad 
>>> optimization apply?
>>
>> struct S1 {
>>      int a;
>>      byte b;
>> }
>>
>> struct S2 {
>>      S1 s1;
>>      char c;
>> }
>>
>> Sé could be 8 byte long (some variation of this are in C++ for
>> instance if I make a public and b private).
>
> Do any C++ compilers do this for this case, or just for the 
> inheritance one?

They do it in the condition mentioned for extern(C++) in my first 
post (at least clang and gcc, C++ ABI isn't well defined, so 
other compiler may do thing differently).


More information about the Digitalmars-d mailing list