Mercurial > hg > tinycc
changeset 473:ec2b47ce2530
Joshua Phillips fixed size of structs with empty array member.
author | Rob Landley <rob@landley.net> |
---|---|
date | Wed, 05 Sep 2007 17:47:17 -0500 |
parents | 5ecdf063c480 |
children | 254e8668fb9d |
files | tcc.c tests/tcctest.c |
diffstat | 2 files changed, 9 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/tcc.c Wed Sep 05 17:36:42 2007 -0500 +++ b/tcc.c Wed Sep 05 17:47:17 2007 -0500 @@ -5849,7 +5849,8 @@ if (a == TOK_STRUCT) { c = (c + align - 1) & -align; offset = c; - c += size; + if (size > 0) + c += size; } else { offset = 0; if (size > c)
--- a/tests/tcctest.c Wed Sep 05 17:36:42 2007 -0500 +++ b/tests/tcctest.c Wed Sep 05 17:47:17 2007 -0500 @@ -794,6 +794,10 @@ { struct1 *s; union union2 u; + struct foo { + int a; + void *b[]; + }; printf("struct:\n"); printf("sizes: %d %d %d %d\n", @@ -833,6 +837,9 @@ /* empty structures (GCC extension) */ printf("sizeof(struct empty) = %d\n", sizeof(struct empty)); printf("alignof(struct empty) = %d\n", __alignof__(struct empty)); + + // Struct with zero size member. + printf("sizeof(struct foo)=%d\n", sizeof(struct foo)); } /* XXX: depend on endianness */ @@ -2183,4 +2190,3 @@ # include <windows.h> # include <gl\glaux.h> #endif -