3 ms·
Hasn't the main issue with MS been VLAs? I seem to recall that VLAs are the main reason MSVC won't ever support C99, and that MSVC is one of the main reasons wh
by mort96 3y ago
Hasn't the main issue with MS been VLAs? I seem to recall that VLAs are the main reason MSVC won't ever support C99, and that MSVC is one of the main reasons why VLAs were made optional. It seems like MSVC supports C11 and C17 now, thanks to the removal of mandatory VLAs.
- zabzonk 3y agovehement oppostion from ms my be one of the reasons for them being optional (and thus worthless) but the main one is that that they are impossible to use correctly. what happens if you make one too big?
- mort96 3y agoI think they could potentially have some very limited valid use cases, but I agree that a fixed length array and/or heap allocation is usually much better than VLAs. I was mainly just pointing out that MS's lack of C99 support isn't really a part of keeping C89 alive, especially now that they officially support C11.
- aragilar 3y agoI'm not sure how robust that support is though: https://discuss.python.org/t/requiring-compilers-c11-standard-mode-to-build-cpython/26481/23 https://discuss.python.org/t/requiring-compilers-c11-standar...
- mort96 3y agoIf the reply is correct, the only issue there is that they're compiling in C89 mode. If you pass `-pedantic -std=c89` to GCC, it too will warn on C99+ features. If you pass `/std:c11` or `/std:c17` to MSVC, C99+ features should work.
- Dylan16807 3y ago> what happens if you make one too big? Doesn't that apply to fixed length arrays too?
- mort96 3y agoIt does, but if you create a fixed length array that's too big, you'll just deterministically blow the stack regardless of user input. With VLAs (or alloca), your array length is determined by some runtime property. Whether you blow the stack doesn't just depend on the code path any more, but on the data you're operating on too. As a bonus, that data is often user input...
- pjmlp 3y agoThe whole security industry has vettoed VLAs. Google even went the extra pay to pay the effort to remove them from the Linux kernel.
- mort96 3y agoYeah, that's my point. The situation isn't, "MS is garbage, they only support C89"; the situation is "MS supports modern C pretty well, their lack of official C99 supports is just a technicality caused by VLAs which you shouldn't use anyway".