https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108896
--- Comment #41 from qinzhao at gcc dot gnu.org --- my private gcc is able to use the element_count information in bound sanitizer now: [opc@qinzhao-ol8u3-x86 108896]$ cat t6.c #include <stdlib.h> #include <assert.h> struct P { int k; int x[] __attribute__ ((element_count ("k"))); } *p; void __attribute__ ((noinline)) store(int a, int b) { p = (struct P *)malloc (sizeof (struct P) + a * sizeof (int)); p->k = a; return; } int main() { store(7, 7); p->x[7] = 1; } [opc@qinzhao-ol8u3-x86 108896]$ sh t /home/opc/Install/latest-d/bin/gcc -O -fsanitize=bounds-strict t6.c t6.c:18:6: runtime error: index 7 out of bounds for type 'int [*]' [opc@qinzhao-ol8u3-x86 108896]$