https://issues.dlang.org/show_bug.cgi?id=18788

Walter Bright <bugzi...@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzi...@digitalmars.com

--- Comment #7 from Walter Bright <bugzi...@digitalmars.com> ---
(In reply to Mike Franklin from comment #0)
>     char[newLen + 1] buf;     // Error: variable newLen cannot be read at
> compile time

I suspect the correct way to handle this would be:

    scope char[] buf = new char[newlen + 1];

The `scope` will ensure `buf` does not escape the stack frame, and so the
compiler can allocate it on the stack.

This is how:

    class C { ... }
    scope C c = new C();

works today.

--

Reply via email to