shithub: scc

Download patch

ref: 38670978b7243e0b2093c553a4c3df03178d9d0a
parent: 4462308d95e9aede0ea42f4262bb082007beb427
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Fri Nov 5 17:47:29 EDT 2021

cc1: Remove wrong optimization in content()

Collapsing OADDR and OPTR is a really bad idea, because
it removes the indirection operation needed.

--- a/src/cmd/cc/cc1/expr.c
+++ b/src/cmd/cc/cc1/expr.c
@@ -470,14 +470,7 @@
 	if (BTYPE(np) != PTR) {
 		errorp("invalid argument of memory indirection");
 	} else {
-		if (np->op == OADDR) {
-			Node *new = np->left;
-			new->type = np->type->type;
-			free(np);
-			np = new;
-		} else {
-			np = node(op, np->type->type, np, NULL);
-		}
+		np = node(op, np->type->type, np, NULL);
 		np->flags |= NLVAL;
 	}
 	return np;