Debian Codegraph @

gcc/testsuite/gcc.dg/pr119717.c

raw
1 /* PR c/119717 */
2 /* { dg-additional-options "-std=c23" } */
3 /* { dg-do compile } */
4
5 struct annotated {
6 unsigned count;
7 [[gnu::counted_by(count)]] char array[];
8 };
9
10 [[gnu::noinline,gnu::noipa]]
11 static unsigned
12 size_of (bool x, struct annotated *a)
13 {
14 char *p = (x ? a : 0)->array;
15 return __builtin_dynamic_object_size (p, 1);
16 }
17
18 int main()
19 {
20 struct annotated *p = __builtin_malloc(sizeof *p);
21 p->count = 0;
22 __builtin_printf ("the bdos whole is %ld\n", size_of (0, p));
23 return 0;
24 }