* tests/test-malloc-gnu.c (main):
* tests/test-realloc-gnu.c (main): Hide true intentions from GCC,
to prevent diagnostics like “warning: argument 1 value
‘
9223372036854775808’ exceeds maximum object size
9223372036854775807 [-Walloc-size-larger-than=]”.
2021-04-18 Paul Eggert <eggert@cs.ucla.edu>
+ malloc-gnu-tests: pacify -Walloc-size-larger-than
+ * tests/test-malloc-gnu.c (main):
+ * tests/test-realloc-gnu.c (main): Hide true intentions from GCC,
+ to prevent diagnostics like “warning: argument 1 value
+ ‘9223372036854775808’ exceeds maximum object size
+ 9223372036854775807 [-Walloc-size-larger-than=]”.
+
safe-alloc: fix pointer implementation
The old implementation assumed that all pointers use the same
internal representation, but the C standard doesn’t guarantee
#include <stdint.h>
int
-main ()
+main (int argc, char **argv)
{
/* Check that malloc (0) is not a NULL pointer. */
char *p = malloc (0);
/* Check that malloc (n) fails when n exceeds PTRDIFF_MAX. */
if (PTRDIFF_MAX < SIZE_MAX)
{
- size_t n = PTRDIFF_MAX, n1 = n + 1;
- if (malloc (n1) != NULL)
+ size_t one = argc != 12345;
+ if (malloc (PTRDIFF_MAX + one) != NULL)
return 1;
}
#include <stdint.h>
int
-main ()
+main (int argc, char **argv)
{
/* Check that realloc (NULL, 0) is not a NULL pointer. */
char *p = realloc (NULL, 0);
PTRDIFF_MAX. */
if (PTRDIFF_MAX < SIZE_MAX)
{
- size_t n = PTRDIFF_MAX, n1 = n + 1;
- if (realloc (p, n1) != NULL)
+ size_t one = argc != 12345;
+ if (realloc (p, PTRDIFF_MAX + one) != NULL)
return 1;
}