Hacker News new | ask | show | jobs
by chjj 1418 days ago
I'm not sure if you intentionally missed my point. Everything in C requires careful usage. VLAs aren't special: they're just yet another feature which must be used carefully, if used at all.

Personally, I don't use them, but I don't find "they're unsafe" to be a convincing reason for why they shouldn't be included in the already-unsafe language. Saying they're unnecessary might be a better reason.

2 comments

The goal should be to reduce the amount of sharp edges, not increase them even further.
VLAs are unsafe in the worst kind of way as it is not possible to query when it is safe to use them. alloca() at least in theory can return null stack overflow, but there is no such provision with VLA.
They're not unsafe (in the memory sense) as long as they check for overflow and reliably crash if there is one.
If a lot of platforms don't implement this check reliably, then it's unsafe in practice at this time, even if not in theory.
Who out there has a version of stack checking that doesn't actually check the stack…? If it doesn't check by default, as C doesn't, then it's not "as long as".