Re:Variable Length Arrays are problematic
by lmilcin on Monday July 05, 2021 @07:57PM
(#27742957)
From my point of view VLA belongs to a class of features (along with, for example, setjump/longjump) that are best not mentioned to novice developers.
Standards aimed at security/reliability (for example MISRA) outright ban using these as they are just not worth the risk.
I have never actually needed VLAs in all the projects I did in ANSI C and I only once used alloca to provide a buffer on a stack for a serializer, but in that case the buffer size was configured at the start of the application and I could most likely just used a buffer provided by the application.
Standards aimed at security/reliability (for example MISRA) outright ban using these as they are just not worth the risk.
I have never actually needed VLAs in all the projects I did in ANSI C and I only once used alloca to provide a buffer on a stack for a serializer, but in that case the buffer size was configured at the start of the application and I could most likely just used a buffer provided by the application.