Re: Obtain pointer from static array literal

2021-10-08 Thread codic via Digitalmars-d-learn
On Friday, 8 October 2021 at 06:59:32 UTC, Nicholas Wilson wrote: On Friday, 8 October 2021 at 05:31:21 UTC, codic wrote: [...] [...] No, I meant what I said. The array literal will cause a GC allocation, unless it is assigned to a static array of the same length or is inferred to be a st

Re: Obtain pointer from static array literal

2021-10-08 Thread russhy via Digitalmars-d-learn
https://run.dlang.io/is/S8uMbp It's such a shame that ``[0,1,2,3].ptr`` allocates using GC, even if using ``func(scope const void* ptr)`` Can't something be done to make this ``[0,1,2,3]`` a static array literal? Who thought making it GC allocated was a good idea? i want names!

Re: Obtain pointer from static array literal

2021-10-08 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 8 October 2021 at 05:31:21 UTC, codic wrote: On Friday, 8 October 2021 at 05:01:00 UTC, Nicholas Wilson wrote: note that if the pointer is not escaped from the function (i.e. thing is void thing(scope int* abc)note the addition of scope) LDC will perform promotion of GC allocation to