Front page | perl.perl5.porters |
Postings from May 2021
Re: C99
Thread Previous
|
Thread Next
From:
Tomasz Konojacki
Date:
May 19, 2021 17:21
Subject:
Re: C99
Message ID:
20210519192101.F755.5C4F47F8@xenu.pl
On Wed, 19 May 2021 13:30:25 +0000
Nicholas Clark <nick@ccl4.org> 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".
Thread Previous
|
Thread Next