1 /* PR tree-optimization/83821 - local aggregate initialization defeats
3 Verify that a strlen() call is not eliminated for a pointer to a region
4 of memory allocated by calloc() if a byte is written into the region
5 that isn't known to be nul.
7 { dg-options "-O2 -fdump-tree-optimized" } */
12 keep_strlen_calloc_store_cst_memset (int i
, unsigned a
, unsigned b
)
14 char *p
= __builtin_calloc (a
, 1);
18 __builtin_memset (p
, 0, b
);
20 n0
= __builtin_strlen (p
);
26 keep_strlen_calloc_store_var_memset (int i
, int x
, unsigned a
, unsigned b
)
28 char *p
= __builtin_calloc (a
, 1);
32 __builtin_memset (p
, 0, b
);
34 n0
= __builtin_strlen (p
);
40 keep_strlen_calloc_store_memset_2 (int i
, int x
, unsigned a
, unsigned b
, unsigned c
)
42 char *p
= __builtin_calloc (a
, 1);
45 __builtin_memset (p
, 0, b
);
47 n0
= __builtin_strlen (p
);
50 __builtin_memset (p
, 0, c
);
52 n1
= __builtin_strlen (p
);
57 /* { dg-final { scan-tree-dump-times "__builtin_strlen" 4 "optimized" } } */