Skip to content

Commit 6034406

Browse files
committed
build: more "undefined behavior" fixes
Fixes #5764. R=golang-dev, bradfitz CC=golang-dev https://golang.org/cl/13441051
1 parent 80a153d commit 6034406

File tree

4 files changed

+5
-3
lines changed

4 files changed

+5
-3
lines changed

src/cmd/6g/gsubr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ ginscon(int as, vlong c, Node *n2)
540540

541541
nodconst(&n1, types[TINT64], c);
542542

543-
if(as != AMOVQ && (c < -1LL<<31 || c >= 1LL<<31)) {
543+
if(as != AMOVQ && (c < -(1LL<<31) || c >= 1LL<<31)) {
544544
// cannot have 64-bit immediokate in ADD, etc.
545545
// instead, MOV into register first.
546546
regalloc(&ntmp, types[TINT64], N);

src/cmd/6l/obj.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ zaddr(char *pn, Biobuf *f, Adr *a, Sym *h[])
346346
a->offset = BGETLE4(f);
347347
if(t & T_64) {
348348
a->offset &= 0xFFFFFFFFULL;
349-
a->offset |= (vlong)BGETLE4(f) << 32;
349+
a->offset |= (uvlong)BGETLE4(f) << 32;
350350
}
351351
}
352352
a->sym = S;

src/cmd/6l/span.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1237,6 +1237,8 @@ doasm(Prog *p)
12371237
break;
12381238
}
12391239

1240+
if(z >= nelem(o->op))
1241+
sysfatal("asmins bad table %P", p);
12401242
op = o->op[z];
12411243
if(op == 0x0f) {
12421244
*andptr++ = op;

src/libbio/bgetc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ Bgetle4(Biobuf *bp)
8383

8484
l = Bgetle2(bp);
8585
h = Bgetle2(bp);
86-
return l|(h<<16);
86+
return l|((uint32)h<<16);
8787
}
8888

8989
int

0 commit comments

Comments
 (0)