Zero-sized struct
<p>According to the C++ standard (inherited from C) empty structs have a non-zero size nevertheless. The reason for this (pitiful IMHO) is that two distinct variables should have different addresses. Now, inheriting an empty struct does not always "inflate" the object. But in some situations this is the case.</p>

<p>I have a pretty sophisticated classes architecture, involving fierce template voodoo. As the result the final classes (instances of which I need to create) may have several empty structs inherited. Due to this fact part of them may be inflated eventually. And the worst part is that their memory layout actually depends on the order of inheritance.</p>

<p>I'd like to get rid of all this, if it's possible.</p>

<p>Is there a C++ compiler that can be configured to eliminate this space waste, in expense of breaking the standard actually?</p>

<p><strong>Edit:</strong></p>

<p>I mean this:</p>

<pre><code>struct Empty1 {};
struct Empty2 {};

struct NonEmpty {
    int Value;
};

struct MyClass1
    :public NonEmpty
    ,public Empty1
    ,public Empty2
{
};

struct MyClass2
    :public Empty1
    ,public NonEmpty
    ,public Empty2
{
};

struct MyClass3
    :public Empty1
    ,public Empty2
    ,public NonEmpty
{
};

STATIC_ASSERT(sizeof(MyClass1) == 8);
STATIC_ASSERT(sizeof(MyClass2) == 4);
STATIC_ASSERT(sizeof(MyClass3) == 8);
</code></pre>

<p>Not only empty structs inflate the object (when more than one such a thing inherited), but also the result depends on the order of inheritance of the empty structs.</p>
