scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | Submodules | README | LICENSE

commit b7ce1b54e474ab65020b7f3b365be963a1bc7aaf
parent 53dfe412fa62329707411264dc02ba98e8c19012
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:
Msrc/cmd/cc/cc1/fold.c | 2+-
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) {