BetterC Bug? Intended Behavior? Asking Here As Unsure
Steven Schveighoffer
schveiguy at gmail.com
Tue Jul 7 12:26:26 UTC 2020
On 7/6/20 5:09 PM, kinke wrote:
> On Monday, 6 July 2020 at 20:25:11 UTC, Kayomn wrote:
>> Though, admittedly I'm kind of used to seeing this error message since
>> it appears any time you try and do something that relies on type info
>> in betterC, intentionally or not. A notable example is forgetting to
>> supply an arrange length when declaring a stack array, or it'll try to
>> create a runtime-allocated array.
>
> Similar case here; the 'varargs' end up in a GC-allocated array. I've
> recently changed `scope` slice params, so that array literal arguments
> are allocated on the caller's stack instead; so adding `scope` for these
> variadics *should* probably do the same:
>
> void tester(Test test, scope Test[] tests...);
Note that without the initial parameter, or without the destructor, they
do NOT end up on the heap.
I think this is a bug, and not a "feature". I can't see any reason why
in those two cases it can construct it on the stack, and in this case it
cannot.
Note that I was under the impression that a Typesafe Variadic would
always be on the stack. Reading the spec, it says it "may" put it on the
stack, which makes me like those types of functions a lot less. Is there
any reason a Typesafe Variadic function called with individual values
cannot be required to put the values on the stack?
-Steve
More information about the Digitalmars-d-learn
mailing list