Package: guile-1.8
Severity: normal

Dear Maintainer,

please find attached two patches which allow to build guile-1.8 on
recent releases. I tested for stretch and buster on i386 and amd64 and
it works fine for me.

Best Regards
Hannes

From f8704dd34ce2f2bd30a7f20ef9a7848047d8ba32 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Hannes=20M=C3=BCller?= <h.c.f.muel...@gmx.de>
Date: Wed, 17 Jul 2019 16:30:16 +0200
Subject: [PATCH] Fix failed test-conversion caused by optimization

It seems (kk / xx == yy) is optimized out, i.e. always true, if kk = xx * yy
is set before 

* libguile/numbers.c (scm_product): robust overflow detection
---
 libguile/numbers.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libguile/numbers.c b/libguile/numbers.c
index 4f5ab31fb..b774e4a44 100644
--- a/libguile/numbers.c
+++ b/libguile/numbers.c
@@ -4461,7 +4461,7 @@ scm_product (SCM x, SCM y)
 	  long yy = SCM_I_INUM (y);
 	  long kk = xx * yy;
 	  SCM k = SCM_I_MAKINUM (kk);
-	  if ((kk == SCM_I_INUM (k)) && (kk / xx == yy))
+	  if (SCM_I_INUM (k)/xx == yy)
 	    return k;
 	  else
 	    {
-- 
2.22.0

From a005ddedbe7e817c55ded6d76cb43fd0f7922165 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Hannes=20M=C3=BCller?= <h.c.f.muel...@gmx.de>
Date: Thu, 18 Jul 2019 13:06:25 +0200
Subject: [PATCH] Fix failed test-num2integral and test-conversion on i386

Above noted tests failed on linux i386 and mingw-w64 for i686.

* libguile/conv-integer.i.c (SCM_TO_TYPE_PROTO):
* libguile/numbers.c (scm_is_signed_integer): restrict inverted sign to
  possible cases
---
 libguile/conv-integer.i.c | 7 ++++---
 libguile/numbers.c        | 7 ++++---
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/libguile/conv-integer.i.c b/libguile/conv-integer.i.c
index 4cf887cb6..7946e462a 100644
--- a/libguile/conv-integer.i.c
+++ b/libguile/conv-integer.i.c
@@ -81,9 +81,10 @@ SCM_TO_TYPE_PROTO (SCM val)
 	    }
 	  else
 	    {
-	      n = -n;
-	      if (n >= 0)
-		goto out_of_range;
+	      if (n != SCM_T_INTMAX_MIN) {
+	        n = -n;
+	        if (n >= 0) goto out_of_range;
+	      }
 	    }
 
 	  if (n >= TYPE_MIN && n <= TYPE_MAX)
diff --git a/libguile/numbers.c b/libguile/numbers.c
index b774e4a44..eb6c98265 100644
--- a/libguile/numbers.c
+++ b/libguile/numbers.c
@@ -5768,9 +5768,10 @@ scm_is_signed_integer (SCM val, scm_t_intmax min, scm_t_intmax max)
 	    }
 	  else
 	    {
-	      n = -n;
-	      if (n >= 0)
-		return 0;
+	      if (n != SCM_T_INTMAX_MIN) {
+	        n = -n;
+	        if (n >= 0) return 0;
+	      }
 	    }
 
 	  return n >= min && n <= max;
-- 
2.22.0

Reply via email to