2 ms·
"Legitimate Use of Variable Length Arrays" There isn't any.* The author shows what's at best a minor convenience, which is in no way worth all the downsides o
by yyyk 7y ago
"Legitimate Use of Variable Length Arrays"
There isn't any.*
The author shows what's at best a minor convenience, which is in no way worth all the downsides of which the author lists. For any actual use he'd have to wrap it in a function, if merely to have an assertion to check the array ranges. Oh, and have a version for compilers which don't support VLAs at all. At which point he might as well do the right thing always instead of VLA.
There author must be aware this isn't worth it. I guess the actual intent of the post was to show the author's knowledge, and indeed the author knows C and taught me some things I didn't know (VLAs are even worse than I thought them to be).
* Note that I'm talking about VLA, not stack allocation. There are better ways to do that when that's useful.
- deleted 7y ago[deleted]