Defeat a malloc optimization by declaring things volatile.

This commit is contained in:
Stan Shebs 2018-05-09 11:28:09 -07:00
parent 40513af8ad
commit 58f9551f5b
5 changed files with 6 additions and 6 deletions

View File

@ -35,8 +35,8 @@ call_free (void *ptr)
int
do_test (void)
{
void *ptr1 = malloc (SIZE);
void *ptr2 = malloc (SIZE);
void *volatile ptr1 = malloc (SIZE);
void *volatile ptr2 = malloc (SIZE);
/* Avoid unwanted output to TTY after an expected memory corruption. */
ignore_stderr();

View File

@ -69,7 +69,7 @@ test_setup (void)
static void
test_large_allocations (size_t size)
{
void * ptr_to_realloc;
void *volatile ptr_to_realloc;
test_setup ();
TEST_VERIFY (malloc (size) == NULL);

View File

@ -33,7 +33,7 @@ merror (const char *msg)
static int
do_test (void)
{
void *p, *q;
void *volatile p, *volatile q;
int save;
errno = 0;

View File

@ -33,7 +33,7 @@ merror (const char *msg)
static int
do_test (void)
{
void *p, *q;
void *volatile p, *volatile q;
errno = 0;

View File

@ -34,7 +34,7 @@ merror (const char *msg)
static int
do_test (void)
{
void *p;
void *volatile p;
unsigned long pagesize = getpagesize ();
unsigned long ptrval;
int save;