Debian Codegraph @

gcc/testsuite/gcc.c-torture/execute/pr84339.c

raw
1 /* PR tree-optimization/84339 */
2
3 struct S { int a; char b[1]; };
4
5 __attribute__((noipa)) int
6 foo (struct S *p)
7 {
8 return __builtin_strlen (&p->b[0]);
9 }
10
11 __attribute__((noipa)) int
12 bar (struct S *p)
13 {
14 return __builtin_strlen (p->b);
15 }
16
17 int
18 main ()
19 {
20 struct S *p = __builtin_malloc (sizeof (struct S) + 16);
21 if (p)
22 {
23 p->a = 1;
24 __builtin_strcpy (p->b, "abcdefg");
25 if (foo (p) != 7 || bar (p) != 7)
26 __builtin_abort ();
27 __builtin_free (p);
28 }
29 return 0;
30 }