Stephen said:
I suspect that VLAs are typically implemented via alloca() or a
functional equivalent. If alloca() had been standardized, we wouldn't
need VLAs in the first place; if you have alloca(), a VLA adds nothing
except saving the programmer a few keystrokes and adding complicated
corner cases to the Standard.
Quoth the Rationale,
"Some implementations provide a function, often called
alloca, which allocates the requested object from automatic
storage; and the object is automatically freed when the
calling function exits. Such a function is not efficiently
implementable in a variety of environments, so it was not
adopted in the Standard."
It does not claim that VLA's *are* efficiently implementable on
systems where alloca() is not, but ...
Also quoth the Rationale,
"C99 adds a new array type called a variable length array
type. The inability to declare arrays whose size is known
only at execution time was often cited as a primary deterrent
to using C as a numerical computing language. Adoption of
some standard notion of execution time arrays was considered
crucial for C’s acceptance in the numerical computing world."
Personally, I think C's part in the battle for the hearts and minds
of numericists is over, and that C should face up to its defeat,
bind up its wounds, and try to slip away from the field lest a
still-healthy combatant bayonet it twixt guggle and zatch. The
Committee evidently felt otherwise, and have bandaged C with the
VLA, armed it with _Complex, given it FP_CONTRACT as first aid, and
encouraged it to make yet one more assault (however restrict-ed)
on the foe's redoubts. Fortran to the left of C, Matlab to the
right of -- oh, sorry; I got carried away on the wild wet waves
(stop that!!!) of metaphor.