From 111ca669ae9e2affde73c27e918c9798da6918ac Mon Sep 17 00:00:00 2001 From: Paul Eggert <eggert@cs.ucla.edu> Date: Thu, 17 Dec 2015 12:56:55 -0800 Subject: [PATCH] intprops-test: work around GCC bug 68971 MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Problem reported by Pádraig Brady in: http://lists.gnu.org/archive/html/bug-gnulib/2015-12/msg00011.html * tests/test-intprops.c: Ignore -Woverflow in GCC 6 and earlier. (main): Add a case that better tests 64-bit long in this area. --- ChangeLog | 8 ++++++++ tests/test-intprops.c | 21 +++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/ChangeLog b/ChangeLog index 6bc0a4921f..4fb4b97db8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2015-12-17 Paul Eggert <eggert@cs.ucla.edu> + + intprops-test: work around GCC bug 68971 + Problem reported by Pádraig Brady in: + http://lists.gnu.org/archive/html/bug-gnulib/2015-12/msg00011.html + * tests/test-intprops.c: Ignore -Woverflow in GCC 6 and earlier. + (main): Add a case that better tests 64-bit long in this area. + 2015-12-09 Pavel Raiskup <praiskup@redhat.com> gnulib-tool: allow multiple --local-dir usage diff --git a/tests/test-intprops.c b/tests/test-intprops.c index 6b11417562..82dc9bf590 100644 --- a/tests/test-intprops.c +++ b/tests/test-intprops.c @@ -21,6 +21,14 @@ #if 4 < __GNUC__ + (3 <= __GNUC_MINOR__) # pragma GCC diagnostic ignored "-Woverlength-strings" # pragma GCC diagnostic ignored "-Wtype-limits" + +/* Work around a bug in GCC 5.3.1 and earlier; see: + https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68971 + Hope it will be fixed by the time GCC 6 comes out. */ +# if __GNUC__ < 6 +# pragma GCC diagnostic ignored "-Woverflow" +# endif + #endif #include <config.h> @@ -30,6 +38,7 @@ #include <stdbool.h> #include <inttypes.h> +#include <limits.h> #include "macros.h" @@ -328,6 +337,18 @@ main (void) || result == INT_MIN * (long int) INT_MIN); } +# ifdef LLONG_MAX + { + long long int result; + ASSERT (INT_MULTIPLY_WRAPV (LONG_MAX, LONG_MAX, &result) + == (LLONG_MAX / LONG_MAX < LONG_MAX)); + ASSERT (INT_MULTIPLY_WRAPV (LONG_MAX, LONG_MAX, &result) + || result == LONG_MAX * (long long int) LONG_MAX); + ASSERT (INT_MULTIPLY_WRAPV (LONG_MIN, LONG_MIN, &result) + || result == LONG_MIN * (long long int) LONG_MIN); + } +# endif + #define CHECK_QUOTIENT(a, b, v) VERIFY (INT_DIVIDE_OVERFLOW (a, b) == (v)) CHECK_QUOTIENT (INT_MIN, -1L, -- 2.39.5