From 01eb489c81e57f9a7adee4fcf64f25925a02084b Mon Sep 17 00:00:00 2001
From: Martin Stjernholm <mast@lysator.liu.se>
Date: Sat, 5 Mar 2011 22:47:51 +0100
Subject: [PATCH] Disabled an unsafe optimization.

---
 src/operators.c | 6 ++++++
 src/peep.in     | 2 ++
 2 files changed, 8 insertions(+)

diff --git a/src/operators.c b/src/operators.c
index be7f3f44ab..2cb243bb81 100644
--- a/src/operators.c
+++ b/src/operators.c
@@ -1854,6 +1854,11 @@ static node *optimize_eq(node *n)
     if(!first_arg || !second_arg)
       Pike_fatal("Couldn't find argument!\n");
 #endif
+
+#if 0
+    /* Disabled these - boolean falsehood is not the same thing as
+     * equality with the integer 0. */
+
     if(node_is_false(*first_arg) && !node_may_overload(*second_arg,LFUN_EQ))
     {
       ret=*second_arg;
@@ -1867,6 +1872,7 @@ static node *optimize_eq(node *n)
       ADD_NODE_REF(*first_arg);
       return mkopernode("`!",ret,0);
     }
+#endif
 
     if (((*second_arg)->token == F_CONSTANT) &&
 	((*second_arg)->u.sval.type == T_STRING) &&
diff --git a/src/peep.in b/src/peep.in
index 7cf9528de1..763180bde2 100644
--- a/src/peep.in
+++ b/src/peep.in
@@ -169,6 +169,8 @@ NUMBER [$1a] BRANCH_WHEN_NON_ZERO: BRANCH($2a)
 // These optimizations are now handled in optimize_eq
 // CONST0 BRANCH_WHEN_EQ: BRANCH_WHEN_ZERO($2a)
 // CONST0 BRANCH_WHEN_NE: BRANCH_WHEN_NON_ZERO($2a)
+//
+// This one is not safe.
 // CONST0 EQ: NOT
 
 EQ BRANCH_WHEN_NON_ZERO: BRANCH_WHEN_EQ ($2a)
-- 
GitLab