Yes, adding makes a difference. The reason node1 has padding bytes, and node3 doesn't, lies in the typical use of zero-length arrays.
Zero-length arrays are usually used with casting: you put a larger object (possibly a variable) in a structure containing a zero-length array. Then you get access to the "rest" of a large object using an array of zero length, which for this purpose must be correctly aligned. The padding byte is inserted before the zero-size array, so int aligned. Since you cannot do this with node3 , padding is not needed.
Example:
struct Message { char Type[3]; int Data[]; // it compiles without putting 0 explicitly }; void ReceiveMessage(unsigned char* buffer, size_t length) { if(length < sizeof(Message)) return; Message* msg = (Message*)buffer; if(!memcmp(msg->Type, "GET", 3)) { HandleGet(msg->Data, (length - sizeof(Message))/sizeof(int)); } else if....
Note: this is pretty hacky, but effective.
alain source share