On NetBSD 8 and 9, in 64-bit mode, I see a test failure:
test-reallocarray fails with exit code 4.

The cause is that when n*s overflows, reallocarray(p,n,s) fails with
errno = EOVERFLOW — unlike other implementations that fail with errno = ENOMEM.
But EOVERFLOW is just as reasonable (even more reasonable, IMO) than ENOMEM
in this case. So, let's allow it, and make the test succeed without
overriding reallocarray().


2021-05-13  Bruno Haible  <br...@clisp.org>

        reallocarray tests: Avoid test failure on NetBSD.
        * tests/test-reallocarray.c (main): Accept EOVERFLOW error code.

diff --git a/tests/test-reallocarray.c b/tests/test-reallocarray.c
index 6de355e..8067542 100644
--- a/tests/test-reallocarray.c
+++ b/tests/test-reallocarray.c
@@ -41,7 +41,8 @@ main ()
       p = reallocarray (p, SIZE_MAX / n + 1, n);
       if (p)
         return 3;
-      if (errno != ENOMEM)
+      if (!(errno == ENOMEM
+            || errno == EOVERFLOW /* NetBSD */))
         return 4;
 
       /* Reallocarray should not crash with zero sizes.  */


Reply via email to