re PR c++/83713 (ICE in do_narrow at gcc/convert.c:474)
authorRichard Biener <rguenther@suse.de>
Mon, 8 Jan 2018 13:24:38 +0000 (13:24 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Mon, 8 Jan 2018 13:24:38 +0000 (13:24 +0000)
2018-01-08  Richard Biener  <rguenther@suse.de>

PR middle-end/83713
* convert.c (do_narrow): Properly guard TYPE_OVERFLOW_WRAPS checks.

* g++.dg/torture/pr83713.C: New testcase.

From-SVN: r256341

gcc/ChangeLog
gcc/convert.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/torture/pr83713.C [new file with mode: 0644]

index cbd431aed83d6703b9b6f036648e3022bcd3b045..b91925a712892bca6514b777cff6d758f4e2b52f 100644 (file)
@@ -1,3 +1,8 @@
+2018-01-08  Richard Biener  <rguenther@suse.de>
+
+       PR middle-end/83713
+       * convert.c (do_narrow): Properly guard TYPE_OVERFLOW_WRAPS checks.
+
 2018-01-08  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/83685
index e168a266ff4b8d149d19de0fcbbfc5da1ad67f73..8c8931f40ed284d80d69eb3c4a23a76f18678073 100644 (file)
@@ -471,8 +471,10 @@ do_narrow (location_t loc,
             type in case the operation in outprec precision
             could overflow.  Otherwise, we would introduce
             signed-overflow undefinedness.  */
-         || ((!TYPE_OVERFLOW_WRAPS (TREE_TYPE (arg0))
-              || !TYPE_OVERFLOW_WRAPS (TREE_TYPE (arg1)))
+         || ((!(INTEGRAL_TYPE_P (TREE_TYPE (arg0))
+                && TYPE_OVERFLOW_WRAPS (TREE_TYPE (arg0)))
+              || !(INTEGRAL_TYPE_P (TREE_TYPE (arg1))
+                   && TYPE_OVERFLOW_WRAPS (TREE_TYPE (arg1))))
              && ((TYPE_PRECISION (TREE_TYPE (arg0)) * 2u
                   > outprec)
                  || (TYPE_PRECISION (TREE_TYPE (arg1)) * 2u
index 133e8e98cefed58aa114f1ed011419f5f79e71d2..d5fd96d05c1c4662a130628a4245ac13ee637780 100644 (file)
@@ -1,3 +1,8 @@
+2018-01-08  Richard Biener  <rguenther@suse.de>
+
+       PR middle-end/83713
+       * g++.dg/torture/pr83713.C: New testcase.
+
 2018-01-08  Tom de Vries  <tom@codesourcery.com>
 
        * gcc.dg/tree-ssa/ssa-dom-cse-2.c: Xfail scan for nvptx.
diff --git a/gcc/testsuite/g++.dg/torture/pr83713.C b/gcc/testsuite/g++.dg/torture/pr83713.C
new file mode 100644 (file)
index 0000000..ca6af04
--- /dev/null
@@ -0,0 +1,12 @@
+// { dg-do compile }
+
+class a
+{
+  char b;
+  void c ();
+};
+void
+a::c ()
+{
+  &b + ((long long) &b & 0);
+}