Xref: utzoo comp.sys.ibm.pc:44487 comp.lang.c:25949 Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!uwm.edu!mailrus!iuvax!maytag!watstat!dmurdoch From: dmurdoch@watstat.waterloo.edu (Duncan Murdoch) Newsgroups: comp.sys.ibm.pc,comp.lang.c Subject: TC bug in sizeof()? Message-ID: <1519@maytag.waterloo.edu> Date: 15 Feb 90 17:47:49 GMT Sender: daemon@maytag.waterloo.edu Reply-To: dmurdoch@watstat.waterloo.edu (Duncan Murdoch) Organization: U. of Waterloo, Ontario Lines: 29 A friend of mine has found something surprising in TC. Neither of us knows C well enough to know for sure that this is a bug, but it looks like one. As illustrated in the program below, if a structure is an odd size, and is compiled with Word alignment, the sizeof function rounds the size up one byte. Is this a bug? Sample program: struct test { char a; char b; char c; } structure; main() { printf("Size of structure= %d\n",sizeof(structure)); } This prints a 3 if compiled with byte alignment, an 4 if compiled with word alignment. Thanks for any help. Please post to comp.sys.ibm.pc, or email to me, as you prefer. Duncan Murdoch