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

Re: C99

Thread Previous | Thread Next
From:
Nicholas Clark
Date:
September 1, 2021 12:54
Subject:
Re: C99
Message ID:
YS94A+/2QJO6YQBR@etla.org
I never replied to this:

> On Mon, 14 Jun 2021 at 01:27, Yuki Kimoto <kimoto.yuki@gmail.com> wrote:
> 
> >
> >
> > 2021-6-12 1:47 Nicholas Clark <nick@ccl4.org> wrote:
> >
> >>
> >>     Add -Werror=vla by default. C99 variable-length arrays are dangerous.
> >>
> >>
> > I feel this is good because I feel risky and unstable about
> > variable-length arrays.

On Tue, Jun 15, 2021 at 02:19:58PM +0200, Eric Herman wrote:
> I agree 100% that variable-length arrays are risky.
> 
> Sadly, it should be noted that this perfectly safe construction:
> 
>     const size_t buf_size = 40;
>     char buf[buf_size];
> 
> is caught as an error by -Werror=vla

I assume (but am not it a position to test) that this code is also an
error on all MSVC versions. (Even the current versions.)

And so, it's not that useful trying to figure out a way set gcc compiler
flags to permit the safe variants (-Wvla-larger-than=... I think) because
we don't really have much *nix specific code.

Nicholas Clark

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About