[PATCH 0/4] RFC samples converting VLA to alloca
Morten Brørup
mb at smartsharesystems.com
Wed Apr 10 09:52:20 CEST 2024
> From: Mattias Rönnblom [mailto:hofors at lysator.liu.se]
> Sent: Wednesday, 10 April 2024 09.32
>
> On 2024-04-08 17:53, Morten Brørup wrote:
> >> From: Tyler Retzlaff [mailto:roretzla at linux.microsoft.com]
> >> Sent: Monday, 8 April 2024 17.27
> >>
[...]
> >> Looks like we need to discuss this at the next techboard meeting.
> >>
> >> * MSVC doesn't support C11 optional VLAs (and never will).
> >> * alloca() is an alternative that is available on all platforms/toolchain
> >> combinations.
> >> * it's reasonable for some VLAs to be turned into regular arrays but it
> >> would be unsatisfactory to be stuck waiting discussions of defining new
> >> constant expression macros on a per-use basis.
> >
> > We must generally stop using VLAs, for many reasons.
>
> What reasons would that be? And which of those reasons are not also
> reasons to stop using alloca().
The reasons against VLAs are the same as why MSVC doesn’t support them; primarily that they are insecure.
The reasons against VLAs and alloca() are the same, except MSVC supports alloca().
>
> > The only available 1:1 replacement is alloca(), so we have to accept that.
> >
> > If anyone still cares about improvements, we can turn alloca()'d arrays into
> regular arrays after this patch series.
> >
> > Alternatives to VLAs are very interesting discussions, but let's not stall
> MSVC progress because of it!
> >
>
> What is this supposed to mean? Finding alternatives to VLAs are required
> to make progress of MSVC support in DPDK.
It means that not enough people contribute to discussing and implementing alternatives, so we have to use the 1:1 replacement alternative, alloca(), to avoid stalling DPDK support for MSVC.
We can discuss and implement alternatives at any time, if anybody cares.
>
> >> * there is resistance to using alloca() vs VLA so my proposal is to
> >> change only the code that is built to target windows.
> >
> > I would prefer to get rid of them all, so the CI can build with -Wvla to
> prevent them from being introduced again.
> > Not a strong preference.
> > On the other hand, the CI's MSVC builds will catch them if used for a
> Windows target.
> > And limiting to Windows code reduces the amount of work, so that's probably
> the most realistic solution.
> >
More information about the dev
mailing list