Re: Static Array Idiom not working anymore.

2018-06-14 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, June 14, 2018 08:40:10 Steven Schveighoffer via Digitalmars-d- learn wrote: > On 6/14/18 7:07 AM, Guillaume Piolat wrote: > > On Tuesday, 12 June 2018 at 15:35:42 UTC, Steven Schveighoffer wrote: > >> No, that's not what I mean. What I mean is: > >> > >> int[] arr = [1,2,3].s; > >>

Re: Static Array Idiom not working anymore.

2018-06-14 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/14/18 7:07 AM, Guillaume Piolat wrote: On Tuesday, 12 June 2018 at 15:35:42 UTC, Steven Schveighoffer wrote: No, that's not what I mean. What I mean is: int[] arr = [1,2,3].s; int[] arr2 = [4,5,6].s; Legally, the compiler is allowed to reuse the stack memory allocated for arr for arr2.

Re: Static Array Idiom not working anymore.

2018-06-14 Thread Guillaume Piolat via Digitalmars-d-learn
On Tuesday, 12 June 2018 at 15:35:42 UTC, Steven Schveighoffer wrote: No, that's not what I mean. What I mean is: int[] arr = [1,2,3].s; int[] arr2 = [4,5,6].s; Legally, the compiler is allowed to reuse the stack memory allocated for arr for arr2. The lifetime of the arr data is over.

Re: Static Array Idiom not working anymore.

2018-06-12 Thread SrMordred via Digitalmars-d-learn
On Tuesday, 12 June 2018 at 16:27:50 UTC, SrMordred wrote: On Tuesday, 12 June 2018 at 15:39:10 UTC, Steven Schveighoffer wrote: Essentially what you had originally was a memory corruption bug (yes, even before the deprecation happened). Oops , that bad. Well, not anymore ;)

Re: Static Array Idiom not working anymore.

2018-06-12 Thread SrMordred via Digitalmars-d-learn
On Tuesday, 12 June 2018 at 15:39:10 UTC, Steven Schveighoffer wrote: Essentially what you had originally was a memory corruption bug (yes, even before the deprecation happened). Oops , that bad.

Re: Static Array Idiom not working anymore.

2018-06-12 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/12/18 10:57 AM, Guillaume Piolat wrote: On Tuesday, 12 June 2018 at 14:44:12 UTC, Steven Schveighoffer wrote: Note to ponce, please update your idioms, this is NOT safe, even within the same function. Just because it does work, doesn't mean it will always work. The language makes no

Re: Static Array Idiom not working anymore.

2018-06-12 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/12/18 10:54 AM, Seb wrote: On Tuesday, 12 June 2018 at 14:35:33 UTC, SrMordred wrote: this idiom for creating static array used to work, but they are failing now. What changed and whats the alternative? (from https://p0nce.github.io/d-idioms/#@nogc-Array-Literals:-Breaking-the-Limits)

Re: Static Array Idiom not working anymore.

2018-06-12 Thread Guillaume Piolat via Digitalmars-d-learn
On Tuesday, 12 June 2018 at 14:44:12 UTC, Steven Schveighoffer wrote: What you are being told is that your memory is not being kept around. Essentially what you had originally was a memory corruption bug (yes, even before the deprecation happened). Don't do that anymore! And a reminder that

Re: Static Array Idiom not working anymore.

2018-06-12 Thread Guillaume Piolat via Digitalmars-d-learn
On Tuesday, 12 June 2018 at 14:44:12 UTC, Steven Schveighoffer wrote: Note to ponce, please update your idioms, this is NOT safe, even within the same function. Just because it does work, doesn't mean it will always work. The language makes no guarantees once the lifetime is over. -Steve

Re: Static Array Idiom not working anymore.

2018-06-12 Thread Seb via Digitalmars-d-learn
On Tuesday, 12 June 2018 at 14:35:33 UTC, SrMordred wrote: this idiom for creating static array used to work, but they are failing now. What changed and whats the alternative? (from https://p0nce.github.io/d-idioms/#@nogc-Array-Literals:-Breaking-the-Limits) T[n] s(T, size_t n)(auto ref

Re: Static Array Idiom not working anymore.

2018-06-12 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/12/18 10:35 AM, SrMordred wrote: this idiom for creating static array used to work, but they are failing now. What changed and whats the alternative? (from https://p0nce.github.io/d-idioms/#@nogc-Array-Literals:-Breaking-the-Limits) T[n] s(T, size_t n)(auto ref T[n] array) pure

Static Array Idiom not working anymore.

2018-06-12 Thread SrMordred via Digitalmars-d-learn
this idiom for creating static array used to work, but they are failing now. What changed and whats the alternative? (from https://p0nce.github.io/d-idioms/#@nogc-Array-Literals:-Breaking-the-Limits) T[n] s(T, size_t n)(auto ref T[n] array) pure nothrow @nogc @safe { return array; }