https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119716
Bug ID: 119716 Summary: segmentation fault when Passing NULL pointer to _bdos with counted_by attribute Product: gcc Version: 15.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: qinzhao at gcc dot gnu.org Target Milestone: --- for the following example: []$ cat t.c #include <stdlib.h> #include <stddef.h> struct annotated { size_t count; char array[] __attribute__ ((counted_by(count))); }; static size_t __attribute__((__noinline__,__noipa__)) size_of (struct annotated * obj) { char *p = obj->array; return __builtin_dynamic_object_size (p, 1); } int main() { __builtin_printf ("the bdos whole is %ld\n", size_of (0)); return 0; } with the latest trunk gcc: gcc -O2 -Wall t2.c t: line 13: 2981300 Segmentation fault (core dumped) ./a.out