On Thu, Dec 05, 2024 at 11:37:45AM +0100, Richard Biener wrote: > * c-c++-common/torture/pr117912-1.c: New testcase. > * c-c++-common/torture/pr117912-2.c: Likewise. > * gcc.dg/torture/pr117912-3.c: Likewise.
Thanks for the patch. I'd certainly suggest to replace the third test with * c-c++-common/torture/pr117912-3.c with following because the test from the PR is just way too ugly and doesn't really test much the __bos value at all, just that it is non-zero and in a very weird way. As for the sccvn change, I'd like to play with it a little bit first if you don't mind. /* { dg-do run } */ struct B {}; struct A { int a; struct B b; char c[]; }; volatile void *p; void __attribute__((noipa)) bar (void *q) { p = q; } __SIZE_TYPE__ __attribute__((noipa)) foo (struct A *p) { bar (&p->b); bar (&p->c); return __builtin_object_size (&p->c, 1); } __SIZE_TYPE__ __attribute__((noipa)) baz (int x) { struct A *p = x ? __builtin_malloc (__builtin_offsetof (struct A, c) + 64) : __builtin_calloc (__builtin_offsetof (struct A, c) + 32, 1); bar (&p->b); bar (&p->c); return __builtin_object_size (&p->c, 1); } __SIZE_TYPE__ __attribute__((noipa)) qux (struct A *p) { bar (&p->b); bar (&p->c); return __builtin_object_size (&p->c, 3); } __SIZE_TYPE__ __attribute__((noipa)) boo (int x) { struct A *p = x ? __builtin_malloc (__builtin_offsetof (struct A, c) + 64) : __builtin_calloc (__builtin_offsetof (struct A, c) + 32, 1); bar (&p->b); bar (&p->c); return __builtin_object_size (&p->c, 3); } int main () { static struct A a = { .a = 1, .b = {}, .c = { 1, 2, 3, 4, 0 } }; if (foo (&a) < 5) __builtin_abort (); if (baz (0) < 64) __builtin_abort (); if (qux (&a) != 0) __builtin_abort (); if (boo (0) > 32) __builtin_abort (); } Jakub