J
JR
Take a look at TestStruct1 and TestStruct2. Clearly, the D2 part of
the union is MUCH larger than the D1 portion. I would expect
sizeof(TestStruct1)==sizeof(TestStruct2) but that is not the case
using Microsoft Visual C++ 2003. Here is what I get
sizeof(TestStruct1)==0x108
sizeof(TestStruct2)==0x104
Is this normal C++ compiler behavior, or a bug in the compiler?
typedef struct _TestStruct1 {
union {
struct {
unsigned __int64 n1;
} D1;
struct {
int n3[64];
int n4;
} D2;
} u;
} TestStruct1, *PTestStruct1;
typedef struct _TestStruct2 {
union {
struct {
int n1;
} D1;
struct {
int n3[64];
int n4;
} D2;
} u;
} TestStruct2, *PTestStruct2;
the union is MUCH larger than the D1 portion. I would expect
sizeof(TestStruct1)==sizeof(TestStruct2) but that is not the case
using Microsoft Visual C++ 2003. Here is what I get
sizeof(TestStruct1)==0x108
sizeof(TestStruct2)==0x104
Is this normal C++ compiler behavior, or a bug in the compiler?
typedef struct _TestStruct1 {
union {
struct {
unsigned __int64 n1;
} D1;
struct {
int n3[64];
int n4;
} D2;
} u;
} TestStruct1, *PTestStruct1;
typedef struct _TestStruct2 {
union {
struct {
int n1;
} D1;
struct {
int n3[64];
int n4;
} D2;
} u;
} TestStruct2, *PTestStruct2;