* fold-const.c (operand_equal_p): Pay attention to side effects.
authorGavin Romig-Koch <gavin@cygnus.com>
Fri, 17 Sep 1999 19:06:50 +0000 (19:06 +0000)
committerGavin Romig-Koch <gavin@gcc.gnu.org>
Fri, 17 Sep 1999 19:06:50 +0000 (19:06 +0000)
From-SVN: r29483

gcc/ChangeLog
gcc/fold-const.c

index fcf41bdc79f7a0ecf6aa39469c6b528bb56622f8..4d0035dfc8f72e818b8f0c83c4f21c9764ed650e 100644 (file)
@@ -1,3 +1,7 @@
+Fri Sep 17 15:05:27 1999  Gavin Romig-Koch  <gavin@cygnus.com>
+
+       * fold-const.c (operand_equal_p): Pay attention to side effects.
+
 Fri Sep 17 11:14:17 1999  Jason Merrill  <jason@yorick.cygnus.com>
 
        * libgcc2.c (L_exit): Check for ON_EXIT, not HAVE_ON_EXIT.
index cddcded25ee7869c3a1905cc5b41060caf230cda..c13b6908c43c8c97e70a9882af6698d0982a9048 100644 (file)
@@ -2183,6 +2183,12 @@ operand_equal_p (arg0, arg1, only_const)
                                  TREE_OPERAND (arg1, 0), 0));
 
     case 'r':
+      /* If either of the pointer (or reference) expressions we are dereferencing
+        contain a side effect, these cannot be equal. */
+      if (TREE_SIDE_EFFECTS (arg0)
+         || TREE_SIDE_EFFECTS (arg1))
+       return 0;
+
       switch (TREE_CODE (arg0))
        {
        case INDIRECT_REF: