libcpp, c, middle-end: Optimize initializers using #embed in C
[official-gcc.git] / gcc / testsuite / gcc.dg / Wstringop-overflow-10.c
blobddc27fc05805aac0ea24f78cca011b671aed46b0
1 /* PR tree-optimization/89500 - ICE: tree check: expected integer_cst,
2 have ssa_name in get_len
3 { dg-do compile }
4 { dg-options "-O2 -Wstringop-overflow -Wstringop-truncation" } */
6 void
7 foo (char *a)
9 char b[16] = "abcdefg";
10 __builtin_strncpy (a, b, __builtin_strlen (b)); /* { dg-warning "specified bound depends on the length of the source argument" } */
13 void
14 bar (char *a)
16 char b[16] = "abcdefg";
17 __builtin_strncpy (a, b, __builtin_strnlen (b, 8)); /* { dg-warning "specified bound depends on the length of the source argument" } */
20 void
21 baz (char *a)
23 char b[16] = "abcdefg";
24 __builtin_strncpy (a, b, __builtin_strnlen (b, 7)); /* { dg-warning "output truncated before terminating nul" } */
27 void fill (char *);
29 void
30 qux (char *a)
32 char b[16];
33 fill (b);
34 __builtin_memcpy (b, "abcdefg", 7);
35 __builtin_strncpy (a, b, __builtin_strnlen (b, 8)); /* { dg-bogus "specified bound depends on the length of the source argument" } */