News for hackers. Stuff that matters.
Re:C for All by enriquto on Saturday March 24, 2018 @10:03AM (#16666622)
A beautiful, and simple, addition to the C language would be a mechanism to assess the remaining stack size. This is trivial to check in assembler, but practically impossible in portable C.

Indeed, thanks to VLA, the stack can be used as a clean notation for raii. You just replace this ugly, but very common, construction

    void f(int n)
    {
            float *x = malloc(n * sizeof*x);
            // ...
            free(x);
    }
with this

    void f(int n)
    {
            float x[n];
            // ...
    }
Re:C for All by BruceIV on Saturday March 24, 2018 @10:54AM (#16666869)
[on the Cforall team] we actually take advantage of this same VLA idiom for temporary storage for polymorphic variables.

Fun fact from when we switched our implementation to use VLAs: if you call alloca() for stack memory instead, it doesn't work properly inside a loop, because it never releases the memory until the stack frame is exited.

Re:C for All by pjmlp on Monday March 26, 2018 @04:56AM (#16677568)
VLAs were made optional in C11 as they became yet another security exploit vector, and not all C vendors are keen in supporting it, especially on the embedded space.