summaryrefslogtreecommitdiff
path: root/tests/test-calloc-gnu.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test-calloc-gnu.c')
-rw-r--r--tests/test-calloc-gnu.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/tests/test-calloc-gnu.c b/tests/test-calloc-gnu.c
index 953bd778b3..eb336e1a6a 100644
--- a/tests/test-calloc-gnu.c
+++ b/tests/test-calloc-gnu.c
@@ -17,6 +17,7 @@
#include <config.h>
#include <stdlib.h>
+#include <stdint.h>
/* Return 8.
Usual compilers are not able to infer something about the return value. */
@@ -49,7 +50,7 @@ main ()
'volatile' is needed to defeat an incorrect optimization by clang 10,
see <https://bugs.llvm.org/show_bug.cgi?id=46055>. */
{
- void * volatile p = calloc ((size_t) -1 / 8 + 1, eight ());
+ void * volatile p = calloc (SIZE_MAX / 8 + 1, eight ());
if (p != NULL)
{
free (p);
@@ -57,5 +58,16 @@ main ()
}
}
+ /* Likewise for PTRDIFF_MAX. */
+ if (PTRDIFF_MAX / 8 < SIZE_MAX)
+ {
+ void * volatile p = calloc (PTRDIFF_MAX / 8 + 1, eight ());
+ if (p != NULL)
+ {
+ free (p);
+ return 2;
+ }
+ }
+
return 0;
}