shithub: mc

Download patch

ref: 3f5b9c674dc0f3e9e43d17acf1b7cfbb409b89d1
parent: 0c0c4f2f6b3606ab6387b92cef21e166bc9c075b
author: Ori Bernstein <ori@eigenstate.org>
date: Sat Oct 7 10:48:04 EDT 2017

Correctly pad small alignments.

	Negative padding shouldn't happen.

--- a/6/blob.c
+++ b/6/blob.c
@@ -255,15 +255,17 @@
 static size_t
 blobucon(Blob *seq, Htab *globls, Htab *strtab, Node *n)
 {
-	size_t sz, pad;
+	size_t sz, align;
 	Ucon *uc;
 
 	sz = 4;
 	uc = finducon(exprtype(n), n->expr.args[0]);
 	b(seq, mkblobi(Bti32, uc->id));
+	align = 1;
 	if (n->expr.nargs > 1) {
-		pad = tyalign(exprtype(n->expr.args[1])) - sz;
-		sz += blobpad(seq, pad);
+		align = tyalign(exprtype(n->expr.args[1]));
+		if (align > sz)
+			sz += blobpad(seq, align - sz);
 		sz += blobrec(seq, globls, strtab, n->expr.args[1]);
 	}
 	sz += blobpad(seq, size(n) - sz);