ref: b1e6e521c437f1180e581e0559d437b4a4660d58
parent: 464235e458f9c68db974ee4fd34a9728fe09c5bd
author: Ori Bernstein <[email protected]>
date: Sun Nov 30 16:04:53 EST 2014
Avoid division by zero deaths in the compiler. Print an error instead of dying.
--- a/mi/fold.c
+++ b/mi/fold.c
@@ -152,6 +152,9 @@
r = val(n->loc, a * b, exprtype(n));
break;
case Odiv:
+ /* x/0 = error */
+ if (isval(args[1], 0))
+ fatal(args[1], "division by zero");
/* x/1 = x */
if (isval(args[1], 1))
r = args[0];