Forum Discussion
ute1405
Feb 03, 2024Copper Contributor
Why the size of type Bar is 3 not 4 in MSVC?
#include <iostream>
using std::cout;
struct Bar {
char name[3];
struct Foo {
int a;
int b;
};
};
int main()
{
cout << sizeof(Bar);
return 0;
} Usually it alig...
FrancisMoore
Mar 31, 2026Iron Contributor
Please note: In the `Bar` structure, there are no members requiring alignment after `char name[3]`, so its size is 3 bytes; it has not been padded to 4 bytes. Simply amend this.