mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-30 22:43:12 +03:00
Fix malloc/ tests for GCC 7 -Walloc-size-larger-than=.
GCC 7 has a -Walloc-size-larger-than= warning for allocations of half the address space or more. This causes errors building glibc tests that deliberately test failure of very large allocations. This patch arranges for this warning to be ignored around the problematic function calls. Tested compilation for aarch64 (GCC mainline) with build-many-glibcs.py; did execution testing for x86_64 (GCC 5). * malloc/tst-malloc.c: Include <libc-internal.h>. (do_test): Disable -Walloc-size-larger-than= around tests of malloc with negative sizes. * malloc/tst-mcheck.c: Include <libc-internal.h>. (do_test): Disable -Walloc-size-larger-than= around tests of malloc and realloc with negative sizes. * malloc/tst-realloc.c: Include <libc-internal.h>. (do_test): Disable -Walloc-size-larger-than= around tests of realloc with negative sizes.
This commit is contained in:
@ -19,6 +19,7 @@
|
||||
#include <errno.h>
|
||||
#include <malloc.h>
|
||||
#include <stdio.h>
|
||||
#include <libc-internal.h>
|
||||
|
||||
static int errors = 0;
|
||||
|
||||
@ -37,7 +38,14 @@ do_test (void)
|
||||
|
||||
errno = 0;
|
||||
|
||||
DIAG_PUSH_NEEDS_COMMENT;
|
||||
#if __GNUC_PREREQ (7, 0)
|
||||
/* GCC 7 warns about too-large allocations; here we want to test
|
||||
that they fail. */
|
||||
DIAG_IGNORE_NEEDS_COMMENT (7, "-Walloc-size-larger-than=");
|
||||
#endif
|
||||
p = malloc (-1);
|
||||
DIAG_POP_NEEDS_COMMENT;
|
||||
save = errno;
|
||||
|
||||
if (p != NULL)
|
||||
@ -67,7 +75,14 @@ do_test (void)
|
||||
if (p == NULL)
|
||||
merror ("malloc (513K) failed.");
|
||||
|
||||
DIAG_PUSH_NEEDS_COMMENT;
|
||||
#if __GNUC_PREREQ (7, 0)
|
||||
/* GCC 7 warns about too-large allocations; here we want to test
|
||||
that they fail. */
|
||||
DIAG_IGNORE_NEEDS_COMMENT (7, "-Walloc-size-larger-than=");
|
||||
#endif
|
||||
q = malloc (-512 * 1024);
|
||||
DIAG_POP_NEEDS_COMMENT;
|
||||
if (q != NULL)
|
||||
merror ("malloc (-512K) succeeded.");
|
||||
|
||||
|
Reference in New Issue
Block a user