Compiling my code as C++11 with gcc 4.8.2
and llvm/clang 3.4
on fedora-linux, I got strange results that I couldn't really explain...
here is a similar program fedora.
#include <iostream>
using namespace std;
struct A {};
struct C {};
struct B1 : A { union { A a;}; };
struct B2 : A { union { C c;}; };
int main()
{
cout << sizeof(B1) << " " << sizeof(B2) << endl;
}
sizeof(B1) = 2
and sizeof(B2) = 1
But why are the sizes different? Actually I have an idea "why", but I want to find the exact explanation or C++ rule.