[PR,87073,committed] fix go bootstrap

Message ID ba4cd00c-9a13-b33b-ee3b-5531e54db31d@redhat.com
State New
Headers show
Series
  • [PR,87073,committed] fix go bootstrap
Related show

Commit Message

Aldy Hernandez Aug. 24, 2018, 8:02 a.m.
I have no idea how this passed bootstrap and tests in other languages.

The problem here is that wide_int_binop is overflowing on TRUNC_DIV_EXPR 
and a range in Go.  This is causing us to use wmin/wmax uninitialized.

Serves me right for all my whining about Ada yesterday.  I think the VRP 
changes are sufficiently all encompassing that I will start testing 
--enable-languages=all instead of whatever our defaults are.  My bad.

Committed as obvious.

Aldy

Comments

H.J. Lu Aug. 24, 2018, 4:56 p.m. | #1
n Fri, Aug 24, 2018 at 1:02 AM Aldy Hernandez <aldyh@redhat.com> wrote:
>

> I have no idea how this passed bootstrap and tests in other languages.

>

> The problem here is that wide_int_binop is overflowing on TRUNC_DIV_EXPR

> and a range in Go.  This is causing us to use wmin/wmax uninitialized.

>

> Serves me right for all my whining about Ada yesterday.  I think the VRP

> changes are sufficiently all encompassing that I will start testing

> --enable-languages=all instead of whatever our defaults are.  My bad.

>

> Committed as obvious.


This patch also fixed:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87092

I am checking in this patch to add a testcase.

-- 
H.J.
From 89dabc2d6e95ebac507cdfe082085af6b3ec4701 Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Fri, 24 Aug 2018 09:50:56 -0700
Subject: [PATCH] Add a testcase for PR middle-end/87092

	PR middle-end/87092
	* gcc.dg/pr87092.c: New.
---
 gcc/testsuite/gcc.dg/pr87092.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
 create mode 100644 gcc/testsuite/gcc.dg/pr87092.c

diff --git a/gcc/testsuite/gcc.dg/pr87092.c b/gcc/testsuite/gcc.dg/pr87092.c
new file mode 100644
index 00000000000..4a6faebbd93
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr87092.c
@@ -0,0 +1,10 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fwrapv" } */
+
+int a, b;
+
+void
+c(void) {
+  if (b)
+    b = a / b;
+}
Aldy Hernandez Aug. 24, 2018, 5:05 p.m. | #2
On 08/24/2018 12:56 PM, H.J. Lu wrote:
> n Fri, Aug 24, 2018 at 1:02 AM Aldy Hernandez <aldyh@redhat.com> wrote:

>>

>> I have no idea how this passed bootstrap and tests in other languages.

>>

>> The problem here is that wide_int_binop is overflowing on TRUNC_DIV_EXPR

>> and a range in Go.  This is causing us to use wmin/wmax uninitialized.

>>

>> Serves me right for all my whining about Ada yesterday.  I think the VRP

>> changes are sufficiently all encompassing that I will start testing

>> --enable-languages=all instead of whatever our defaults are.  My bad.

>>

>> Committed as obvious.

> 

> This patch also fixed:

> 

> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87092

> 

> I am checking in this patch to add a testcase.

> 


Thank you.

Patch

gcc/

	PR 87073/bootstrap
	* wide-int-range.cc (wide_int_range_div): Do not ignore result
	from wide_int_range_multiplicative_op.

diff --git a/gcc/wide-int-range.cc b/gcc/wide-int-range.cc
index cbc71c25cfe..3cdcede04cd 100644
--- a/gcc/wide-int-range.cc
+++ b/gcc/wide-int-range.cc
@@ -687,14 +687,11 @@  wide_int_range_div (wide_int &wmin, wide_int &wmax,
 
   /* If we know we won't divide by zero, just do the division.  */
   if (!wide_int_range_includes_zero_p (divisor_min, divisor_max, sign))
-    {
-      wide_int_range_multiplicative_op (wmin, wmax, code, sign, prec,
-					dividend_min, dividend_max,
-					divisor_min, divisor_max,
-					overflow_undefined,
-					overflow_wraps);
-      return true;
-    }
+    return wide_int_range_multiplicative_op (wmin, wmax, code, sign, prec,
+					     dividend_min, dividend_max,
+					     divisor_min, divisor_max,
+					     overflow_undefined,
+					     overflow_wraps);
 
   /* If flag_non_call_exceptions, we must not eliminate a division
      by zero.  */