ref: f90d96846e1b756b01cb983b9e117cfb03dd755f
parent: d95c5300d65d7416a1b0d31d34d648c6a1a70373
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Mon Nov 1 05:24:21 EDT 2021
cc1: Simplify not initilized fields When a field is not specified in an initializer then it is initialized to 0 casted to the correct type. Since the code was not simplifying that expression we had a cast that were not understood by cc2, generating wrong code.
--- a/src/cmd/cc/cc1/code.c
+++ b/src/cmd/cc/cc1/code.c
@@ -357,7 +357,10 @@
case PTR:
case INT:
case ENUM:
- aux = (sym) ? *sym->u.init : convert(constnode(zero), tp, 0);
+ if (sym)
+ aux = *sym->u.init;
+ else
+ aux = simplify(convert(constnode(zero), tp, 0));
emitexp(OEXPR, aux);
break;
case UNION: