diff options
Diffstat (limited to 'gcc/testsuite/gcc.dg/pr119717.c')
-rw-r--r-- | gcc/testsuite/gcc.dg/pr119717.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/pr119717.c b/gcc/testsuite/gcc.dg/pr119717.c new file mode 100644 index 0000000..e5eedc5 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr119717.c @@ -0,0 +1,24 @@ +/* PR c/119717 */ +/* { dg-additional-options "-std=c23" } */ +/* { dg-do compile } */ + +struct annotated { + unsigned count; + [[gnu::counted_by(count)]] char array[]; +}; + +[[gnu::noinline,gnu::noipa]] +static unsigned +size_of (bool x, struct annotated *a) +{ + char *p = (x ? a : 0)->array; + return __builtin_dynamic_object_size (p, 1); +} + +int main() +{ + struct annotated *p = __builtin_malloc(sizeof *p); + p->count = 0; + __builtin_printf ("the bdos whole is %ld\n", size_of (0, p)); + return 0; +} |