]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c/61741 (wrong code with -fno-strict-overflow)
authorRichard Biener <rguenther@suse.de>
Wed, 9 Jul 2014 17:14:11 +0000 (17:14 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Wed, 9 Jul 2014 17:14:11 +0000 (17:14 +0000)
2014-07-09  Richard Biener  <rguenther@suse.de>

PR c-family/61741
* c-gimplify.c (c_gimplify_expr): Gimplify self-modify expressions
using unsigned arithmetic if overflow does not wrap instead of
if overflow is undefined.

* c-c++-common/torture/pr61741.c: New testcase.

From-SVN: r212400

gcc/c-family/ChangeLog
gcc/c-family/c-gimplify.c
gcc/testsuite/ChangeLog
gcc/testsuite/c-c++-common/torture/pr61741.c [new file with mode: 0644]

index 5bd9c1e435ca72256f00f8b52f74587031e9ed90..24455978734fc88a8f656ec0daeb7d53f050ae15 100644 (file)
@@ -1,3 +1,10 @@
+2014-07-09  Richard Biener  <rguenther@suse.de>
+
+       PR c-family/61741
+       * c-gimplify.c (c_gimplify_expr): Gimplify self-modify expressions
+       using unsigned arithmetic if overflow does not wrap instead of
+       if overflow is undefined.
+
 2014-07-06  Marek Polacek  <polacek@redhat.com>
 
        PR c/6940
index 16bffd297bd65c896832a032eb81eef04bd33bf4..8fbff603ca8a7b6d5d2f302e42b4ef41fc13f68e 100644 (file)
@@ -240,9 +240,7 @@ c_gimplify_expr (tree *expr_p, gimple_seq *pre_p ATTRIBUTE_UNUSED,
        tree type = TREE_TYPE (TREE_OPERAND (*expr_p, 0));
        if (INTEGRAL_TYPE_P (type) && c_promoting_integer_type_p (type))
          {
-           if (TYPE_OVERFLOW_UNDEFINED (type)
-               || ((flag_sanitize & SANITIZE_SI_OVERFLOW)
-                   && !TYPE_OVERFLOW_WRAPS (type)))
+           if (!TYPE_OVERFLOW_WRAPS (type))
              type = unsigned_type_for (type);
            return gimplify_self_mod_expr (expr_p, pre_p, post_p, 1, type);
          }
index 77cddaf5157de39fe4dadc304e19efe370226ba9..b2e6a0168b89c0f2243bc51865603a8da30f2ade 100644 (file)
@@ -1,3 +1,8 @@
+2014-07-09  Richard Biener  <rguenther@suse.de>
+
+       PR c-family/61741
+       * c-c++-common/torture/pr61741.c: New testcase.
+
 2014-07-09  Pat Haugen  <pthaugen@us.ibm.com>
 
        * lib/target-supports.exp
diff --git a/gcc/testsuite/c-c++-common/torture/pr61741.c b/gcc/testsuite/c-c++-common/torture/pr61741.c
new file mode 100644 (file)
index 0000000..b5f9b93
--- /dev/null
@@ -0,0 +1,22 @@
+/* { dg-do run } */
+
+int a = 1, b;
+
+void
+foo (void)
+{
+  char c = 0;
+  for (; a; a--)
+    for (; c >= 0; c++);
+  if (!c)
+    b = 1;
+}
+
+int
+main ()
+{
+  foo ();
+  if (b != 0)
+    __builtin_abort ();
+  return 0;
+}