commit 84ef54ce07723eddf2f17a5fb9d959fc31c77100
parent d23527d9b83c725a054a56fe7f5d956c485129df
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date: Mon, 15 Nov 2021 21:38:51 +0100
cc1: Avoid non symbol nodes in foldcast()
Foldcast() expects that the left child is a constant
node with a constant symbol. There are some cases
where some constant nodes are not going to have associated
a constant symbol, like for example the case of the address
of a static variable.
Diffstat:
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/cmd/cc/cc1/fold.c b/src/cmd/cc/cc1/fold.c
@@ -321,7 +321,7 @@ foldcast(Node *np, Node *l)
Type *newtp = np->type, *oldtp = l->type;
Symbol aux, *sym, *osym = l->sym;
- if ((l->flags & NCONST) == 0)
+ if ((l->flags & NCONST) == 0 || !osym)
return np;
switch (newtp->op) {