1 /* { dg-do compile } */
2 /* { dg-options "-O2 -Wall" } */
4 extern void abort (void);
6 #include "../gcc.c-torture/execute/builtins/chk.h"
8 extern char *mallocminus1(int size
) __attribute__((alloc_size(-1))); /* { dg-warning "parameter outside range" } */
9 extern char *malloc0(int size
) __attribute__((alloc_size(0))); /* { dg-warning "parameter outside range" } */
10 extern char *malloc1(int size
) __attribute__((alloc_size(1)));
11 extern char *malloc2(int empty
, int size
) __attribute__((alloc_size(2)));
12 extern char *calloc1(int size
, int elements
) __attribute__((alloc_size(1,2)));
13 extern char *calloc2(int size
, int empty
, int elements
) __attribute__((alloc_size(1,3)));
14 extern char *balloc1(void *size
) __attribute__((alloc_size(1)));
25 strcpy (p
, "Hello World"); /* { dg-warning "will always overflow" "strcpy" } */
26 p
= malloc2 (__INT_MAX__
>= 1700000 ? 424242 : __INT_MAX__
/ 4, 6);
28 strcpy (p
, "Hello World"); /* { dg-warning "will always overflow" "strcpy" } */
31 strcpy (p
, "Hello World"); /* { dg-warning "will always overflow" "strcpy" } */
32 p
= calloc2 (2, __INT_MAX__
>= 1700000 ? 424242 : __INT_MAX__
/ 4, 5);
34 strcpy (p
, "Hello World"); /* { dg-warning "will always overflow" "strcpy" } */