2007-03-22 Zoltan Varga <vargaz@gmail.com>
authorZoltan Varga <vargaz@gmail.com>
Thu, 22 Mar 2007 16:42:30 +0000 (16:42 -0000)
committerZoltan Varga <vargaz@gmail.com>
Thu, 22 Mar 2007 16:42:30 +0000 (16:42 -0000)
* cfold.c (FOLD_BINOP): Cast the result to gint32 to prevent overflow problems
on 64 bit machines. Fixes part of #80738.

* basic.cs: Add regression test.

svn path=/trunk/mono/; revision=74815

mono/mini/ChangeLog
mono/mini/basic.cs
mono/mini/cfold.c

index e1eec111614264ecd15beaa80142a1d532fdb444..2ceb476034cdaf4e1a33f098c72e922f0b2f3998 100644 (file)
@@ -1,3 +1,10 @@
+2007-03-22  Zoltan Varga  <vargaz@gmail.com>
+
+       * cfold.c (FOLD_BINOP): Cast the result to gint32 to prevent overflow problems
+       on 64 bit machines. Fixes part of #80738.
+
+       * basic.cs: Add regression test.
+
 2007-03-17  Zoltan Varga  <vargaz@gmail.com>
 
        * inssel.brg basic.cs: Revert previous change to fix build.
index 9d87228509a2dbc7bb72542dde387c63c7a3e2cb..1e7cbb1186fa45a2ca1957f9e257d48847812bfb 100644 (file)
@@ -1274,4 +1274,12 @@ class Tests {
 
                return 0;
        }
+
+       public static int test_0_regress_cprop_80738 () {
+               int hours = Int32.MinValue;
+               int hrssec = (hours * 3600); // break point at (Int32.MaxValue - 596523)
+               long t = ((long)(hrssec) * 1000L);
+
+               return t == 0 ? 0 : 1;
+       }
 }
index c9daabdb7f6c5d4c781fafb13ba90adec44ec3c3..81580ce9ec8fad4198de16a290757408702c6e2d 100644 (file)
@@ -29,7 +29,7 @@ mono_is_power_of_two (guint32 val)
                        return; \
                if (inst->inst_i1->opcode == OP_ICONST) {       \
                        inst->opcode = OP_ICONST;       \
-                       inst->inst_c0 = inst->inst_i0->inst_c0 op inst->inst_i1->inst_c0;       \
+                       inst->inst_c0 = (gint32)(inst->inst_i0->inst_c0 op inst->inst_i1->inst_c0);     \
                } \
                 return;
 
@@ -43,7 +43,7 @@ mono_is_power_of_two (guint32 val)
                if (inst->inst_i0->opcode == OP_ICONST) {\
                        if (inst->inst_i1->opcode == OP_ICONST) {       \
                                inst->opcode = OP_ICONST;       \
-                               inst->inst_c0 = inst->inst_i0->inst_c0 op inst->inst_i1->inst_c0;       \
+                               inst->inst_c0 = (gint32)(inst->inst_i0->inst_c0 op inst->inst_i1->inst_c0);     \
                                 return; \
                        } else { \
                                MonoInst *tmp = inst->inst_i0;  \