blob: 32d5991b4218757fe7be159cd7c0ea1dcb1d01b6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
/* { dg-skip-if "requires hosted libstdc++ for stdlib calloc" { ! hostedlib } } */
#include <stdlib.h>
#include <string.h>
typedef unsigned char Byte;
typedef unsigned int uInt;
typedef unsigned long uLong;
#define Z_NULL 0
int test ()
{
uLong comprLen = 10000*sizeof(int);
uLong uncomprLen = comprLen;
Byte *compr = (Byte*)calloc((uInt)comprLen, 1);
Byte *uncompr = (Byte*)calloc((uInt)uncomprLen, 1);
if (compr == Z_NULL || uncompr == Z_NULL)
{
return 1; /* { dg-warning "leak of 'uncompr'" "uncompr leak" } */
/* { dg-warning "leak of 'compr'" "compr leak" { target *-*-* } .-1 } */
}
strcpy((char*)uncompr, "garbage");
return 0; /* { dg-warning "leak of 'uncompr'" "uncompr leak" } */
/* { dg-warning "leak of 'compr'" "compr leak" { target *-*-* } .-1 } */
}
|