summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2016-07-15 21:13:35 +0200
committercinap_lenrek <cinap_lenrek@felloff.net>2016-07-15 21:13:35 +0200
commit95524b1cdd24091d8d677d4c7a0bb8492f1a7961 (patch)
tree6bf03be41c9aedd03f5a58f270ff4d4366eb70d7
parentde1e74abd21007b75e456a7810f923a5043ada87 (diff)
5c: fix int -> uvlong cast bug (thanks to qwx on his patience on a the trouble session to narrowing it down)
we used to not sign extend if the destination was unsigned uvlong, which is wrong. we have to sign extend only based on the signedness of the source (it gets propagated to vlong) this bug hit in hjfs in the newentry() function, causing file creation to fail with "create -- phase error": newentry(...) { uvlong sj; int si; ... sj = si = -1; ... }
-rw-r--r--sys/src/cmd/5c/cgen.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/sys/src/cmd/5c/cgen.c b/sys/src/cmd/5c/cgen.c
index a85271565..42421f6cc 100644
--- a/sys/src/cmd/5c/cgen.c
+++ b/sys/src/cmd/5c/cgen.c
@@ -961,7 +961,7 @@ cgen64(Node *n, Node *nn)
reg[nn->right->reg] = 0;
cgen(l, &nod1);
reg[nn->right->reg] = a;
- if(typeu[n->type->etype] || typeu[l->type->etype])
+ if(typeu[l->type->etype])
gmove(nodconst(0), nn->right);
else
gopcode(OASHR, nodconst(31), &nod1, nn->right);