ref: b63876162fb895fc497021b19d74fae77d5cc2bb
parent: 7477ca9d9a6687226a2bedbfaecac212d40d4436
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Fri Sep 6 22:11:18 EDT 2019
cc: fix void cast crash
the following code reproduces the crash:
void
foo(void)
{
}
void
main(int argc, char **argv)
{
(void)(1 ? (void)0 : foo());
}
the problem is that side() gives a false positive on the OCOND
with later constant folding eleminating the acutal side effect
and OCAST ending up with two nested OCATS with the nested one
being zapped (type == T).
--- a/sys/src/cmd/cc/com.c
+++ b/sys/src/cmd/cc/com.c
@@ -1081,6 +1081,11 @@
if(castucom(n))
warn(n, "32-bit unsigned complement zero-extended to 64 bits");
ccom(l);
+ if(l->type == T){+ n->left = Z;
+ n->type = T;
+ break;
+ }
if(l->op == OCONST) {evconst(n);
if(n->op == OCONST)
--
⑨