develooper Front page | perl.perl5.porters | Postings from May 2021

Re: C99

Thread Previous | Thread Next
Tomasz Konojacki
May 19, 2021 17:21
Re: C99
Message ID:
On Wed, 19 May 2021 13:30:25 +0000
Nicholas Clark <> wrote:

> I have put the current version at

That list includes Variable Length Arrays, but it doesn't mention their
numerous drawbacks. Just like gets() they're *extremely* unsafe.

VLAs are allocated on the stack. The stack in C tends to be rather small
(in the order of a few megabytes), so it's very easy to overflow it.
There's no portable way to find out how much stack space is available.
VLAs don't signal errors, they just overflow the stack when you request
too much memory.

C11 has made VLAs optional (in C99 they were mandatory) and some
compliant compilers (e.g. Visual C++) have chosen not to implement it.

I think not only we shouldn't use them, but also we should explictly ban
them with something like "-Wvla -Werror=vla".

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About