Why were variable length arrays made optional in C 2011

cc++11language-features

When VLAs were introduced in C 1999, I thought it was a great innovation to the language. However, having learned it was made optional in C 2011, I am wondering what led to its change in status, and if it means the feature is actually headed for obsolescence. If so, is there an equivalent notion of automatic management of dynamically sized data that is being considered to replace it?

I attempted to find the C 2011 rationale document, but it does not seem to be published yet.

Best Answer

I've heard legends varying from "it should be optional as some small compilers should be able to be C11-compliant without VLAs" to "it was a mistake on the first place". I've never got one true and definite answer to this, though. Ultimately, I don't believe anyone really has one as the reason (assuming - and hoping - there is one) was never disclosed (as far as my old searches went).


From Chapter 4 (page 13) of Rationale for International Standard - Programming Languages - C 5.10 (2003)

By defining conforming implementations in terms of the programs they accept, the Standard leaves open the door for a broad class of extensions as part of a conforming implementation. By defining both conforming hosted and conforming freestanding implementations, the Standard recognizes the use of C to write such programs as operating systems and ROM-based applications, as well as more conventional hosted applications. Beyond this two-level scheme, no additional subsetting is defined for C, since the C89 Committee felt strongly that too many levels dilutes the effectiveness of a standard.

Emphasis mine. Notice that this decision goes against their own rationale. Yet, another thing made optional. Now you either get __STDC_NO_VLA__ or VLA support. It is a very odd decision.