VLA在C11中变成了可选特性,VC目前还不支持可选特性,但是承诺后续会增加一些:
While there is currently no support for any C11 optional features, we are committed to providing the most impactful optional features in future releases.
对于为啥不支持VLA,MS自己有一段说辞:
Variable Length Arrays
Astute readers will note that VLAs are also not supported. Variable length arrays are generally less efficient than comparable fixed sized arrays, and generally inefficient compared to equivalent malloc(), when safely and securely implemented. VLAs provide attack vectors comparable to those of the infamous gets() — deprecated and destined to removal — for opportunities of “shifting the stack” and other exploits. For these reasons we intend not to support VLAs as an optional feature in C11.
这个blog也说了VC在C上面为何这么一直“懒”“矬”的原因:
For many years Visual Studio has only supported C to the extent of it being required for C++.
blog地址:
https://devblogs.microsoft.com/cppblog/c11-and-c17-standard-support-arriving-in-msvc/
【 在 dormouseBHU 的大作中提到: 】
: 连 VLA 都不支持,VS也好意思说自己支持 C11。。。
:
--
FROM 114.240.244.*