aboutsummaryrefslogtreecommitdiffhomepage
path: root/c/c.c
diff options
context:
space:
mode:
Diffstat (limited to 'c/c.c')
-rw-r--r--c/c.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/c/c.c b/c/c.c
index 2b2688d..a6c61fc 100644
--- a/c/c.c
+++ b/c/c.c
@@ -1717,9 +1717,10 @@ initializer(struct comp *cm, union type *ty, enum evalmode ev, bool globl,
} else {
uint siz;
if (isincomplete(*ty)) {
- if (!ip->arrlen)
+ uint len = ip->arrlen > ip->cur->idx ? ip->arrlen : ip->cur->idx;
+ if (!len)
error(&span, "initializer creates a zero-sized array");
- *ty = mkarrtype(typechild(*ty), ty->flag & TFCHLDQUAL, ip->arrlen > 0 ? ip->arrlen : 1);
+ *ty = mkarrtype(typechild(*ty), ty->flag & TFCHLDQUAL, len);
}
assert(arraylength(res.zero) == 1);