i've been strugling with an troublesome compiler bug i think.
for the following code you would expect the total struct size to be 5 however that is not the case.
1 2 3 4 5
struct tagTest
{
char a; // 1 byte large
int b; // 4 bytes large
}
Somehow when i debug my program and ask for the sizeof(tagTest) the size was transformed into 8 bytes.
so i tried to see what was wrong and come to the conclusion that when a char is declared before any other type than char it automaticly takes over the size of the type in memory.
I'm using microsoft visual studio 2012.
I am wondering if its compiler side or just a rule within c++ and how i can solve this to be how it should be.