Does 'D' language supports 'C' like VLA?

Steven Schveighoffer via Digitalmars-d digitalmars-d at puremagic.com
Mon Apr 13 11:01:23 PDT 2015


On 4/13/15 1:34 PM, BS & LD wrote:
> On Monday, 13 April 2015 at 17:24:38 UTC, Steven Schveighoffer wrote:
>> D doesn't do this, you have to know the size of the stack array at
>> compile time. You can use alloca, which will give you some runtime
>> allocation of stack, but it can be dangerous (as noted).
>>
>
> I don't know how things are handled here but it will be very nice if
> someone could make the language support this.

It's very unlikely this will make it into the language. Alloca should be 
good enough for this, it's not a very common usage, and supporting it is 
not easy.

>> Value range propagation (the compiler understanding what values a
>> variable can be at some point in time) only is inside one statement.
>> It does not remember what szArr can be at a later statement.
>
> Although I think it will be a nice feature if it can. I would prefer
> slower compilation then slower code.

It requires flow analysis, and that is not something I think any of the 
compiler devs are willing to add at this point.

-Steve


More information about the Digitalmars-d mailing list