Wrong size of empty struct in MS mode.

Hi all!

I found that in MS mode following struct
struct A
{
};
will have null size.
But if I compile with Itanium ABI this struct will have size = 1.

Is that normal?
If it is not then problem is in this condition
if (!isMicrosoftCXXABI() || RD->getNumVBases())
     FinishLayout(RD);

from Layout method in RecordLayoutBuilder.cpp (line 1404).
I suggest to rewrite this condition on something like this
if (!isMicrosoftCXXABI())
     FinishLayout(RD);
else if (!RD->getNumVBases())
     FinishLayout(RD);

  - Dmitry.

Hi all!

I found that in MS mode following struct
struct A
{
};
will have null size.
But if I compile with Itanium ABI this struct will have size = 1.

Is that normal?

A struct in C++ can't have zero size.

If it is not then problem is in this condition
if (!isMicrosoftCXXABI() || RD->getNumVBases())
FinishLayout(RD);

from Layout method in RecordLayoutBuilder.cpp (line 1404).
I suggest to rewrite this condition on something like this
if (!isMicrosoftCXXABI())
FinishLayout(RD);
else if (!RD->getNumVBases())
FinishLayout(RD);

The correct solution is probably to sink this check into FinishLayout
after we handle empty structs.

-Eli