mirror of
https://sourceware.org/git/glibc.git
synced 2025-08-08 17:42:12 +03:00
malloc: obscure calloc use in tst-calloc
Similar toa9944a52c9
andf9493a15ea
, we need to hide calloc use from the compiler to accommodate GCC's r15-6566-g804e9d55d9e54c change. First, include tst-malloc-aux.h, but then use `volatile` variables for size. The test passes without the tst-malloc-aux.h change but IMO we want it there for consistency and to avoid future problems (possibly silent). Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
This commit is contained in:
@@ -23,6 +23,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <libc-diag.h>
|
#include <libc-diag.h>
|
||||||
|
|
||||||
|
#include "tst-malloc-aux.h"
|
||||||
|
|
||||||
/* Number of samples per size. */
|
/* Number of samples per size. */
|
||||||
#define N 50000
|
#define N 50000
|
||||||
@@ -94,16 +95,19 @@ random_test (void)
|
|||||||
static void
|
static void
|
||||||
null_test (void)
|
null_test (void)
|
||||||
{
|
{
|
||||||
|
/* Obscure allocation size from the compiler. */
|
||||||
|
volatile size_t max_size = UINT_MAX;
|
||||||
|
volatile size_t zero_size = 0;
|
||||||
/* If the size is 0 the result is implementation defined. Just make
|
/* If the size is 0 the result is implementation defined. Just make
|
||||||
sure the program doesn't crash. The result of calloc is
|
sure the program doesn't crash. The result of calloc is
|
||||||
deliberately ignored, so do not warn about that. */
|
deliberately ignored, so do not warn about that. */
|
||||||
DIAG_PUSH_NEEDS_COMMENT;
|
DIAG_PUSH_NEEDS_COMMENT;
|
||||||
DIAG_IGNORE_NEEDS_COMMENT (10, "-Wunused-result");
|
DIAG_IGNORE_NEEDS_COMMENT (10, "-Wunused-result");
|
||||||
calloc (0, 0);
|
calloc (0, 0);
|
||||||
calloc (0, UINT_MAX);
|
calloc (0, max_size);
|
||||||
calloc (UINT_MAX, 0);
|
calloc (max_size, 0);
|
||||||
calloc (0, ~((size_t) 0));
|
calloc (0, ~((size_t) zero_size));
|
||||||
calloc (~((size_t) 0), 0);
|
calloc (~((size_t) zero_size), 0);
|
||||||
DIAG_POP_NEEDS_COMMENT;
|
DIAG_POP_NEEDS_COMMENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user