Not only this, but also out of bounds accesses using UBSan:
https://godbolt.org/z/q9qsax7qY
(also compiler support is still improving)
https://godbolt.org/z/q9qsax7qY
(also compiler support is still improving)
It basically shows that if you use automatic VLA you have can do some checks on VLA.
But if I prohibit automatic VLA altogether and use fixed size array, I don't need to worry about that at all and the example falls back to what I presented with UBSan doing just its regular thing.