Front page | perl.perl5.porters |
Postings from May 2021
From: Tomasz Konojacki
May 19, 2021 17:21
Message ID: 20210519192101.F755.5C4F47F8@xenu.pl
On Wed, 19 May 2021 13:30:25 +0000
Nicholas Clark <email@example.com> wrote:
> I have put the current version at https://github.com/Perl/perl5/wiki/C99
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".