diff --git a/tccgen.c b/tccgen.c index c25a2243..145d88de 100644 --- a/tccgen.c +++ b/tccgen.c @@ -1253,7 +1253,7 @@ static void patch_type(Sym *sym, CType *type) } else { if ((sym->type.t & VT_ARRAY) && type->ref->c >= 0) { /* set array size if it was omitted in extern declaration */ - sym->type.ref->c = type->ref->c; + sym->type.ref = type->ref; } if ((type->t ^ sym->type.t) & VT_STATIC) tcc_warning("storage mismatch for redefinition of '%s'", diff --git a/tests/tcctest.c b/tests/tcctest.c index efc31e26..9f920777 100644 --- a/tests/tcctest.c +++ b/tests/tcctest.c @@ -1767,9 +1767,13 @@ struct complexinit2 cix22 = { }; typedef int arrtype1[]; +arrtype1 sinit19; +arrtype1 sinit20; arrtype1 sinit19 = {1}; arrtype1 sinit20 = {2,3}; typedef int arrtype2[3]; +arrtype2 sinit21; +arrtype2 sinit22; arrtype2 sinit21 = {4}; arrtype2 sinit22 = {5,6,7};