]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/gc: prepare for 64-bit ints
authorRuss Cox <rsc@golang.org>
Mon, 24 Sep 2012 18:59:44 +0000 (14:59 -0400)
committerRuss Cox <rsc@golang.org>
Mon, 24 Sep 2012 18:59:44 +0000 (14:59 -0400)
This CL makes the compiler understand that the type of
the len or cap of a map, slice, or string is 'int', not 'int32'.
It does not change the meaning of int, but it should make
the eventual change of the meaning of int in 6g a bit smoother.

Update #2188.

R=ken, dave, remyoudompheng
CC=golang-dev
https://golang.org/cl/6542059

16 files changed:
src/cmd/5g/galign.c
src/cmd/6g/cgen.c
src/cmd/6g/galign.c
src/cmd/6g/gg.h
src/cmd/6g/gobj.c
src/cmd/6g/gsubr.c
src/cmd/6g/reg.c
src/cmd/8g/galign.c
src/cmd/gc/align.c
src/cmd/gc/gen.c
src/cmd/gc/go.h
src/cmd/gc/obj.c
src/cmd/gc/reflect.c
src/cmd/gc/runtime.go
src/cmd/gc/sinit.c
src/cmd/gc/walk.c

index 0708042179136b21bb80632812becca1fd58efaa..1fbf633f900496d1774ec69cd3da96e94d900ebe 100644 (file)
@@ -27,6 +27,7 @@ void
 betypeinit(void)
 {
        widthptr = 4;
+       widthint = 4;
 
        zprog.link = P;
        zprog.as = AGOK;
index 89d35450e046519a6bc86a7a63b5d27554034fd6..ce3a3eba9ab74dabd0691f85520490db68f87ef5 100644 (file)
@@ -309,7 +309,7 @@ cgen(Node *n, Node *res)
 
        case OLEN:
                if(istype(nl->type, TMAP) || istype(nl->type, TCHAN)) {
-                       // map and chan have len in the first 32-bit word.
+                       // map and chan have len in the first int-sized word.
                        // a zero pointer means zero length
                        regalloc(&n1, types[tptr], res);
                        cgen(nl, &n1);
@@ -320,7 +320,7 @@ cgen(Node *n, Node *res)
 
                        n2 = n1;
                        n2.op = OINDREG;
-                       n2.type = types[TINT32];
+                       n2.type = types[simtype[TINT]];
                        gmove(&n2, &n1);
 
                        patch(p1, pc);
@@ -333,7 +333,7 @@ cgen(Node *n, Node *res)
                        // both slice and string have len one pointer into the struct.
                        // a zero pointer means zero length
                        igen(nl, &n1, res);
-                       n1.type = types[TUINT32];
+                       n1.type = types[simtype[TUINT]];
                        n1.xoffset += Array_nel;
                        gmove(&n1, res);
                        regfree(&n1);
@@ -344,7 +344,7 @@ cgen(Node *n, Node *res)
 
        case OCAP:
                if(istype(nl->type, TCHAN)) {
-                       // chan has cap in the second 32-bit word.
+                       // chan has cap in the second int-sized word.
                        // a zero pointer means zero length
                        regalloc(&n1, types[tptr], res);
                        cgen(nl, &n1);
@@ -355,8 +355,8 @@ cgen(Node *n, Node *res)
 
                        n2 = n1;
                        n2.op = OINDREG;
-                       n2.xoffset = 4;
-                       n2.type = types[TINT32];
+                       n2.xoffset = widthint;
+                       n2.type = types[simtype[TINT]];
                        gmove(&n2, &n1);
 
                        patch(p1, pc);
@@ -367,7 +367,7 @@ cgen(Node *n, Node *res)
                }
                if(isslice(nl->type)) {
                        igen(nl, &n1, res);
-                       n1.type = types[TUINT32];
+                       n1.type = types[simtype[TUINT]];
                        n1.xoffset += Array_cap;
                        gmove(&n1, res);
                        regfree(&n1);
@@ -596,7 +596,7 @@ agen(Node *n, Node *res)
                                        nlen.type = types[tptr];
                                        nlen.xoffset += Array_array;
                                        gmove(&nlen, &n3);
-                                       nlen.type = types[TUINT32];
+                                       nlen.type = types[simtype[TUINT]];
                                        nlen.xoffset += Array_nel-Array_array;
                                }
                        }
@@ -621,7 +621,7 @@ agen(Node *n, Node *res)
                                nlen.type = types[tptr];
                                nlen.xoffset += Array_array;
                                gmove(&nlen, &n3);
-                               nlen.type = types[TUINT32];
+                               nlen.type = types[simtype[TUINT]];
                                nlen.xoffset += Array_nel-Array_array;
                        }
                }
@@ -656,9 +656,9 @@ agen(Node *n, Node *res)
                        v = mpgetfix(nr->val.u.xval);
                        if(isslice(nl->type) || nl->type->etype == TSTRING) {
                                if(!debug['B'] && !n->bounded) {
-                                       nodconst(&n2, types[TUINT32], v);
-                                       gins(optoas(OCMP, types[TUINT32]), &nlen, &n2);
-                                       p1 = gbranch(optoas(OGT, types[TUINT32]), T, +1);
+                                       nodconst(&n2, types[simtype[TUINT]], v);
+                                       gins(optoas(OCMP, types[simtype[TUINT]]), &nlen, &n2);
+                                       p1 = gbranch(optoas(OGT, types[simtype[TUINT]]), T, +1);
                                        ginscall(panicindex, -1);
                                        patch(p1, pc);
                                }
@@ -683,7 +683,7 @@ agen(Node *n, Node *res)
 
                if(!debug['B'] && !n->bounded) {
                        // check bounds
-                       t = types[TUINT32];
+                       t = types[simtype[TUINT]];
                        if(is64(nr->type))
                                t = types[TUINT64];
                        if(isconst(nl, CTSTR)) {
@@ -1350,7 +1350,7 @@ componentgen(Node *nr, Node *nl)
                gmove(&nodr, &nodl);
 
                nodl.xoffset += Array_nel-Array_array;
-               nodl.type = types[TUINT32];
+               nodl.type = types[simtype[TUINT]];
 
                if(nr != N) {
                        nodr.xoffset += Array_nel-Array_array;
@@ -1360,7 +1360,7 @@ componentgen(Node *nr, Node *nl)
                gmove(&nodr, &nodl);
 
                nodl.xoffset += Array_cap-Array_nel;
-               nodl.type = types[TUINT32];
+               nodl.type = types[simtype[TUINT]];
 
                if(nr != N) {
                        nodr.xoffset += Array_cap-Array_nel;
@@ -1383,7 +1383,7 @@ componentgen(Node *nr, Node *nl)
                gmove(&nodr, &nodl);
 
                nodl.xoffset += Array_nel-Array_array;
-               nodl.type = types[TUINT32];
+               nodl.type = types[simtype[TUINT]];
 
                if(nr != N) {
                        nodr.xoffset += Array_nel-Array_array;
index b03ac1ed674fff6979f8238e120ac8da04c10762..a5d10eb575895e6b1f1ac1a510a799754d9fe153 100644 (file)
@@ -27,6 +27,7 @@ void
 betypeinit(void)
 {
        widthptr = 8;
+       widthint = 4;
 
        zprog.link = P;
        zprog.as = AGOK;
index 4073e228c69e2b44ab10eef0aa66e7944646b3c7..4cca99d5b93eda787fb64dd99ecc1246727e3f9c 100644 (file)
@@ -21,7 +21,7 @@ struct        Addr
        Sym*    gotype;
        Sym*    sym;
        Node*   node;
-       int     width;
+       int64   width;
        uchar   type;
        uchar   index;
        uchar   etype;
index 8c9208374a45f93763d20c82a94ef139b52fd954..07ee32d6a211405d5a66b7030f7df1f33e2e3c23 100644 (file)
@@ -312,8 +312,8 @@ datastring(char *s, int len, Addr *a)
        a->type = D_EXTERN;
        a->sym = sym;
        a->node = sym->def;
-       a->offset = widthptr+4;  // skip header
-       a->etype = TINT32;
+       a->offset = widthptr+widthint;  // skip header
+       a->etype = simtype[TINT];
 }
 
 /*
@@ -324,7 +324,7 @@ void
 datagostring(Strlit *sval, Addr *a)
 {
        Sym *sym;
-       
+
        sym = stringsym(sval->s, sval->len);
        a->type = D_EXTERN;
        a->sym = sym;
@@ -386,10 +386,10 @@ gdatastring(Node *nam, Strlit *sval)
        p->to.type = D_ADDR;
 //print("%P\n", p);
 
-       nodconst(&nod1, types[TINT32], sval->len);
+       nodconst(&nod1, types[TINT], sval->len);
        p = gins(ADATA, nam, &nod1);
-       p->from.scale = types[TINT32]->width;
-       p->from.offset += types[tptr]->width;
+       p->from.scale = widthint;
+       p->from.offset += widthptr;
 }
 
 int
@@ -408,7 +408,7 @@ dstringptr(Sym *s, int off, char *str)
        datastring(str, strlen(str)+1, &p->to);
        p->to.index = p->to.type;
        p->to.type = D_ADDR;
-       p->to.etype = TINT32;
+       p->to.etype = simtype[TINT];
        off += widthptr;
 
        return off;
@@ -432,7 +432,7 @@ dgostrlitptr(Sym *s, int off, Strlit *lit)
        datagostring(lit, &p->to);
        p->to.index = p->to.type;
        p->to.type = D_ADDR;
-       p->to.etype = TINT32;
+       p->to.etype = simtype[TINT];
        off += widthptr;
 
        return off;
index ea64b8821d87e01ea2b9edd91b110d7c17521cbb..638ba4add694a870eee74841c5ed58b3368e9b96 100644 (file)
@@ -1247,9 +1247,9 @@ naddr(Node *n, Addr *a, int canemitcode)
                naddr(n->left, a, canemitcode);
                if(a->type == D_CONST && a->offset == 0)
                        break;  // len(nil)
-               a->etype = TUINT32;
+               a->etype = simtype[TUINT];
                a->offset += Array_nel;
-               a->width = 4;
+               a->width = widthint;
                if(a->offset >= unmappedzero && a->offset-Array_nel < unmappedzero)
                        checkoffset(a, canemitcode);
                break;
@@ -1259,9 +1259,9 @@ naddr(Node *n, Addr *a, int canemitcode)
                naddr(n->left, a, canemitcode);
                if(a->type == D_CONST && a->offset == 0)
                        break;  // cap(nil)
-               a->etype = TUINT32;
+               a->etype = simtype[TUINT];
                a->offset += Array_cap;
-               a->width = 4;
+               a->width = widthint;
                if(a->offset >= unmappedzero && a->offset-Array_cap < unmappedzero)
                        checkoffset(a, canemitcode);
                break;
@@ -2086,12 +2086,12 @@ oindex:
        if(!debug['B'] && !n->bounded) {
                // check bounds
                n4.op = OXXX;
-               t = types[TUINT32];
+               t = types[simtype[TUINT]];
                if(o & ODynam) {
                        if(o & OAddable) {
                                n2 = *l;
                                n2.xoffset += Array_nel;
-                               n2.type = types[TUINT32];
+                               n2.type = types[simtype[TUINT]];
                                if(is64(r->type)) {
                                        t = types[TUINT64];
                                        regalloc(&n4, t, N);
@@ -2102,7 +2102,7 @@ oindex:
                                n2 = *reg;
                                n2.xoffset = Array_nel;
                                n2.op = OINDREG;
-                               n2.type = types[TUINT32];
+                               n2.type = types[simtype[TUINT]];
                                if(is64(r->type)) {
                                        t = types[TUINT64];
                                        regalloc(&n4, t, N);
@@ -2180,8 +2180,8 @@ oindex_const:
                        n1.type = types[tptr];
                        n1.xoffset = Array_nel;
                        nodconst(&n2, types[TUINT64], v);
-                       gins(optoas(OCMP, types[TUINT32]), &n1, &n2);
-                       p1 = gbranch(optoas(OGT, types[TUINT32]), T, +1);
+                       gins(optoas(OCMP, types[simtype[TUINT]]), &n1, &n2);
+                       p1 = gbranch(optoas(OGT, types[simtype[TUINT]]), T, +1);
                        ginscall(panicindex, -1);
                        patch(p1, pc);
                }
@@ -2223,9 +2223,9 @@ oindex_const_sudo:
        if(!debug['B'] && !n->bounded) {
                a->offset += Array_nel;
                nodconst(&n2, types[TUINT64], v);
-               p1 = gins(optoas(OCMP, types[TUINT32]), N, &n2);
+               p1 = gins(optoas(OCMP, types[simtype[TUINT]]), N, &n2);
                p1->from = *a;
-               p1 = gbranch(optoas(OGT, types[TUINT32]), T, +1);
+               p1 = gbranch(optoas(OGT, types[simtype[TUINT]]), T, +1);
                ginscall(panicindex, -1);
                patch(p1, pc);
                a->offset -= Array_nel;
index a139b1caa35593c206db955b50f6de406e049e5b..3352895e75f14e343948aff1e33ac5dfff2ddd3a 100644 (file)
@@ -945,7 +945,8 @@ Bits
 mkvar(Reg *r, Adr *a)
 {
        Var *v;
-       int i, t, n, et, z, w, flag;
+       int i, t, n, et, z, flag;
+       int64 w;
        uint32 regu;
        int32 o;
        Bits bit;
@@ -998,7 +999,7 @@ mkvar(Reg *r, Adr *a)
        o = a->offset;
        w = a->width;
        if(w < 0)
-               fatal("bad width %d for %D", w, a);
+               fatal("bad width %lld for %D", w, a);
 
        flag = 0;
        for(i=0; i<nvar; i++) {
index 4526a2efbe3b5a026c3c589339fdd4bfa58b0a8e..2c8aaa0a41e6faf0493273517e2ccd7e3adec4f9 100644 (file)
@@ -27,6 +27,7 @@ void
 betypeinit(void)
 {
        widthptr = 4;
+       widthint = 4;
 
        zprog.link = P;
        zprog.as = AGOK;
index 6982bbe560e913ac73aa4aab14a2786cfd467f95..2d3756dfc26157238a379d5e271d96fdd7a88792 100644 (file)
@@ -615,12 +615,12 @@ typeinit(void)
        }
 
        Array_array = rnd(0, widthptr);
-       Array_nel = rnd(Array_array+widthptr, types[TUINT32]->width);
-       Array_cap = rnd(Array_nel+types[TUINT32]->width, types[TUINT32]->width);
-       sizeof_Array = rnd(Array_cap+types[TUINT32]->width, widthptr);
+       Array_nel = rnd(Array_array+widthptr, widthint);
+       Array_cap = rnd(Array_nel+widthint, widthint);
+       sizeof_Array = rnd(Array_cap+widthint, widthptr);
 
        // string is same as slice wo the cap
-       sizeof_String = rnd(Array_nel+types[TUINT32]->width, widthptr);
+       sizeof_String = rnd(Array_nel+widthint, widthptr);
 
        dowidth(types[TSTRING]);
        dowidth(idealstring);
index 9b667775eb3d7930d16782fb0897616f72e981aa..780141567720797542b98bab831235f58e9a9552 100644 (file)
@@ -763,7 +763,7 @@ cgen_eface(Node *n, Node *res)
  * generate:
  *     res = s[lo, hi];
  * n->left is s
- * n->list is (cap(s)-lo(TUINT32), hi-lo(TUINT32)[, lo*width(TUINTPTR)])
+ * n->list is (cap(s)-lo(TUINT), hi-lo(TUINT)[, lo*width(TUINTPTR)])
  * caller (cgen) guarantees res is an addable ONAME.
  */
 void
@@ -780,14 +780,14 @@ cgen_slice(Node *n, Node *res)
        // dst.len = hi [ - lo ]
        dst = *res;
        dst.xoffset += Array_nel;
-       dst.type = types[TUINT32];
+       dst.type = types[simtype[TUINT]];
        cgen(len, &dst);
 
        if(n->op != OSLICESTR) {
                // dst.cap = cap [ - lo ]
                dst = *res;
                dst.xoffset += Array_cap;
-               dst.type = types[TUINT32];
+               dst.type = types[simtype[TUINT]];
                cgen(cap, &dst);
        }
 
index 37ed4fa0da90d7d9b99e780a234599e041441031..89b91f666594cba26af97537c2aa2c398ae78762 100644 (file)
@@ -905,6 +905,7 @@ EXTERN      int     hasdefer;               // flag that curfn has defer statetment
 EXTERN Node*   curfn;
 
 EXTERN int     widthptr;
+EXTERN int     widthint;
 
 EXTERN Node*   typesw;
 EXTERN Node*   nblank;
index 8094671cb26b0228bc27ddc292836c8de3ee054a..6f7098dd4e3f34c3935ed8be76a456ee1e3b605d 100644 (file)
@@ -302,8 +302,8 @@ stringsym(char *s, int len)
        off = 0;
        
        // string header
-       off = dsymptr(sym, off, sym, widthptr+4);
-       off = duint32(sym, off, len);
+       off = dsymptr(sym, off, sym, widthptr+widthint);
+       off = duintxx(sym, off, len, widthint);
        
        // string data
        for(n=0; n<len; n+=m) {
index 52b38d71670945762a9aa561ace80a5aafc28a6a..52f77b86f7cd3f16e72d0e1a0f0e6e3b7627d029 100644 (file)
@@ -378,9 +378,9 @@ dextratype(Sym *sym, int off, Type *t, int ptroff)
        }
 
        // slice header
-       ot = dsymptr(s, ot, s, ot + widthptr + 2*4);
-       ot = duint32(s, ot, n);
-       ot = duint32(s, ot, n);
+       ot = dsymptr(s, ot, s, ot + widthptr + 2*widthint);
+       ot = duintxx(s, ot, n, widthint);
+       ot = duintxx(s, ot, n, widthint);
 
        // methods
        for(a=m; a; a=a->link) {
@@ -780,13 +780,13 @@ ok:
 
                // two slice headers: in and out.
                ot = rnd(ot, widthptr);
-               ot = dsymptr(s, ot, s, ot+2*(widthptr+2*4));
+               ot = dsymptr(s, ot, s, ot+2*(widthptr+2*widthint));
                n = t->thistuple + t->intuple;
-               ot = duint32(s, ot, n);
-               ot = duint32(s, ot, n);
-               ot = dsymptr(s, ot, s, ot+1*(widthptr+2*4)+n*widthptr);
-               ot = duint32(s, ot, t->outtuple);
-               ot = duint32(s, ot, t->outtuple);
+               ot = duintxx(s, ot, n, widthint);
+               ot = duintxx(s, ot, n, widthint);
+               ot = dsymptr(s, ot, s, ot+1*(widthptr+2*widthint)+n*widthptr);
+               ot = duintxx(s, ot, t->outtuple, widthint);
+               ot = duintxx(s, ot, t->outtuple, widthint);
 
                // slice data
                for(t1=getthisx(t)->type; t1; t1=t1->down, n++)
@@ -808,9 +808,9 @@ ok:
                // ../../pkg/runtime/type.go:/InterfaceType
                ot = dcommontype(s, ot, t);
                xt = ot - 2*widthptr;
-               ot = dsymptr(s, ot, s, ot+widthptr+2*4);
-               ot = duint32(s, ot, n);
-               ot = duint32(s, ot, n);
+               ot = dsymptr(s, ot, s, ot+widthptr+2*widthint);
+               ot = duintxx(s, ot, n, widthint);
+               ot = duintxx(s, ot, n, widthint);
                for(a=m; a; a=a->link) {
                        // ../../pkg/runtime/type.go:/imethod
                        ot = dgostringptr(s, ot, a->name);
@@ -853,9 +853,9 @@ ok:
                }
                ot = dcommontype(s, ot, t);
                xt = ot - 2*widthptr;
-               ot = dsymptr(s, ot, s, ot+widthptr+2*4);
-               ot = duint32(s, ot, n);
-               ot = duint32(s, ot, n);
+               ot = dsymptr(s, ot, s, ot+widthptr+2*widthint);
+               ot = duintxx(s, ot, n, widthint);
+               ot = duintxx(s, ot, n, widthint);
                for(t1=t->type; t1!=T; t1=t1->down) {
                        // ../../pkg/runtime/type.go:/structField
                        if(t1->sym && !t1->embedded) {
index 7ab24a0440f406259f3791bf6ef5a5ba612e6b33..28c6b44bc6026353446d36b0f4b2e138e3f5142e 100644 (file)
@@ -46,8 +46,6 @@ func appendstr(typ *byte, x []byte, y string) []byte
 
 func cmpstring(string, string) int
 func eqstring(string, string) bool
-func slicestring(string, int, int) string
-func slicestring1(string, int) string
 func intstring(int64) string
 func slicebytetostring([]byte) string
 func slicerunetostring([]rune) string
@@ -55,7 +53,7 @@ func stringtoslicebyte(string) []byte
 func stringtoslicerune(string) []rune
 func stringiter(string, int) int
 func stringiter2(string, int) (retk int, retv rune)
-func copy(to any, fr any, wid uint32) int
+func copy(to any, fr any, wid uintptr) int
 func slicestringcopy(to any, fr any) int
 
 // interface conversions
@@ -109,7 +107,7 @@ func selectnbsend(chanType *byte, hchan chan<- any, elem any) bool
 func selectnbrecv(chanType *byte, elem *any, hchan <-chan any) bool
 func selectnbrecv2(chanType *byte, elem *any, received *bool, hchan <-chan any) bool
 
-func newselect(size int) (sel *byte)
+func newselect(size int32) (sel *byte)
 func selectsend(sel *byte, hchan chan<- any, elem *any) (selected bool)
 func selectrecv(sel *byte, hchan <-chan any, elem *any) (selected bool)
 func selectrecv2(sel *byte, hchan <-chan any, elem *any, received *bool) (selected bool)
index 1ee1696fee1910c508050b999b094ccc24863c8e..8e943e45a1ad48e5d473a7c83fe600ab2adab149 100644 (file)
@@ -300,9 +300,9 @@ staticcopy(Node *l, Node *r, NodeList **out)
                        n1.xoffset = l->xoffset + Array_array;
                        gdata(&n1, nod(OADDR, a, N), widthptr);
                        n1.xoffset = l->xoffset + Array_nel;
-                       gdata(&n1, r->right, 4);
+                       gdata(&n1, r->right, widthint);
                        n1.xoffset = l->xoffset + Array_cap;
-                       gdata(&n1, r->right, 4);
+                       gdata(&n1, r->right, widthint);
                        return 1;
                }
                // fall through
@@ -403,9 +403,9 @@ staticassign(Node *l, Node *r, NodeList **out)
                        n1.xoffset = l->xoffset + Array_array;
                        gdata(&n1, nod(OADDR, a, N), widthptr);
                        n1.xoffset = l->xoffset + Array_nel;
-                       gdata(&n1, r->right, 4);
+                       gdata(&n1, r->right, widthint);
                        n1.xoffset = l->xoffset + Array_cap;
-                       gdata(&n1, r->right, 4);
+                       gdata(&n1, r->right, widthint);
                        // Fall through to init underlying array.
                        l = a;
                }
@@ -1232,11 +1232,11 @@ slice:
        gdata(&nam, nl, types[tptr]->width);
 
        nam.xoffset += Array_nel-Array_array;
-       nodconst(&nod1, types[TINT32], nr->type->bound);
-       gdata(&nam, &nod1, types[TINT32]->width);
+       nodconst(&nod1, types[TINT], nr->type->bound);
+       gdata(&nam, &nod1, widthint);
 
        nam.xoffset += Array_cap-Array_nel;
-       gdata(&nam, &nod1, types[TINT32]->width);
+       gdata(&nam, &nod1, widthint);
 
        goto yes;
 
index c6b7e4278f74ec6e843999c42507a7eb00810409..9e6d57c860a9eadc0205f69a3e9d9bad907d0ba8 100644 (file)
@@ -2496,7 +2496,7 @@ sliceany(Node* n, NodeList **init)
        chk1 = N;
        chk2 = N;
 
-       bt = types[TUINT32];
+       bt = types[simtype[TUINT]];
        if(hb != N && hb->type->width > 4)
                bt = types[TUINT64];
        if(lb != N && lb->type->width > 4)
@@ -2546,18 +2546,18 @@ sliceany(Node* n, NodeList **init)
        n->right = N;
        n->list = nil;
        if(lb == N)
-               bound = conv(bound, types[TUINT32]);
+               bound = conv(bound, types[simtype[TUINT]]);
        else
-               bound = nod(OSUB, conv(bound, types[TUINT32]), conv(lb, types[TUINT32]));
+               bound = nod(OSUB, conv(bound, types[simtype[TUINT]]), conv(lb, types[simtype[TUINT]]));
        typecheck(&bound, Erv);
        walkexpr(&bound, init);
        n->list = list(n->list, bound);
 
        // len = hi [ - lo]
        if(lb == N)
-               hb = conv(hb, types[TUINT32]);
+               hb = conv(hb, types[simtype[TUINT]]);
        else
-               hb = nod(OSUB, conv(hb, types[TUINT32]), conv(lb, types[TUINT32]));
+               hb = nod(OSUB, conv(hb, types[simtype[TUINT]]), conv(lb, types[simtype[TUINT]]));
        typecheck(&hb, Erv);
        walkexpr(&hb, init);
        n->list = list(n->list, hb);