5 ms·
They were made optional in C11. Compilers for DSPs or whatever where VLAs aren't practical don't have to implement them. Just because an _optional_ feature is
by PeCaN 11y ago
They were made optional in C11. Compilers for DSPs or whatever where VLAs aren't practical don't have to implement them.
Just because an _optional_ feature is impractical on a few niche architectures doesn't mean it's a mistake.
- _kst_ 11y agoYes, but that could have been addressed by making them optional for freestanding implementations but mandatory for hosted implementations. Are there any hosted systems (systems that can support the standard library) on which VLAs are difficult to implement?
- PeCaN 11y agoNot as far as I'm aware. POWER, x86(_64), even Itanium all just bump a stack pointer[1]. SPARC has a funky stack, but I don't know enough about it to say how hard VLAs would be. (It's a darn cool architecture though. I wish acquiring a modern SPARC processor wasn't ridiculously expensive.) The thing that makes VLAs hard to implement is that on some embedded and special purpose processors the stack is actually a physical, fixed-size location on the chip. I recall, but can't seem to find, some architecture that didn't use an explicit stack pointer. 1. Itanium has 2, but for purposes of VLAs it may as well have a conventional stack.
- loeg 11y ago> because an _optional_ feature is impractical on a few niche architectures That isn't why it's a mistake. Arrays and the stack don't mesh well together, especially arrays that aren't bounded by anything other than the width of the integral type used for the VLA length.