4 ms·
> VLAs do not have extra bounds checking. Actually, they allow for some limited size checking in function parameters [0], but GCC added this feature only very
by Jorengarenar 3y ago
> VLAs do not have extra bounds checking.
Actually, they allow for some limited size checking in function parameters [0], but GCC added this feature only very recently
[0]: [link redacted]
- uecker 3y agoNot only this, but also out of bounds accesses using UBSan: https://godbolt.org/z/q9qsax7qY https://godbolt.org/z/q9qsax7qY (also compiler support is still improving)
- Jorengarenar 3y agoI'm not sure about this example. 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.
- uecker 3y agoIf you have larger fixed size array you can get an error when you overflow the larger array. But this then does not necessarily prevent invalid accesses to the parts of the array which go beyond the actual size of what is stored in it or might not prevent bound overflows when copying from the array to some other place.