I see new warnings on 32 bit leading to build failure with -Werror=overflow
Hopefully the attached addresses it appropriately.
It seems that the test is depending on undefined behavior though?
I also fixed an example givien in a comment in intprops.h,
and was also unsure of the original intent here.

cheers,
Pádraig.

>From 764813d087f06409f327be1e2f1ba1b7397b64ae Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?P=C3=A1draig=20Brady?= <p...@draigbrady.com>
Date: Thu, 17 Dec 2015 13:54:41 +0000
Subject: [PATCH] intprops-test: fix compilation warning on 32 bit

Compiling on 32 bit gave the following error:
test-intprops.c:325:34: error: integer overflow in expression
             || result == INT_MAX * (long int) INT_MAX);

* tests/test-intprops.c [__GNUC__]: Ignore -Werror=overflow.
* lib/intprops.h: Fix an incorrect example in a comment.
---
 ChangeLog             | 6 ++++++
 lib/intprops.h        | 2 +-
 tests/test-intprops.c | 1 +
 3 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 6bc0a49..664948c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2015-12-17  Pádraig Brady  <p...@draigbrady.com>
+
+	intprops: fix test compilation error on 32 bit
+	* tests/test-intprops.c: Suppress the -Werror=overflow warning.
+	* lib/intprops.h: Fix an incorrect example in a comment.
+
 2015-12-09  Pavel Raiskup  <prais...@redhat.com>
 
 	gnulib-tool: allow multiple --local-dir usage
diff --git a/lib/intprops.h b/lib/intprops.h
index 8fff86d..d002b79 100644
--- a/lib/intprops.h
+++ b/lib/intprops.h
@@ -272,7 +272,7 @@
 
    Example usage, assuming A and B are long int:
 
-     long int result = INT_MULTIPLY_WRAPV (a, b);
+     long int result = a * b;
      printf ("result is %ld (%s)\n", result,
              INT_MULTIPLY_OVERFLOW (a, b) ? "after overflow" : "no overflow");
 
diff --git a/tests/test-intprops.c b/tests/test-intprops.c
index 6b11417..e432fd0 100644
--- a/tests/test-intprops.c
+++ b/tests/test-intprops.c
@@ -21,6 +21,7 @@
 #if 4 < __GNUC__ + (3 <= __GNUC_MINOR__)
 # pragma GCC diagnostic ignored "-Woverlength-strings"
 # pragma GCC diagnostic ignored "-Wtype-limits"
+# pragma GCC diagnostic ignored "-Woverflow"
 #endif
 
 #include <config.h>
-- 
2.5.0

Reply via email to