Re: miscellaneous array questions...

2020-07-21 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 21 July 2020 at 19:20:28 UTC, Simen Kjærås wrote: Walter gives some justification in the post immediately following: whelp proves my memory wrong!

Re: miscellaneous array questions...

2020-07-21 Thread Simen Kjærås via Digitalmars-d-learn
On Tuesday, 21 July 2020 at 13:42:15 UTC, Steven Schveighoffer wrote: On 7/21/20 8:34 AM, Adam D. Ruppe wrote: The others aren't wrong about stack size limits playing some role, but the primary reason is that it is a weird hack for @safe, believe it or not. ... I don't recall exactly when

Re: miscellaneous array questions...

2020-07-21 Thread Johan via Digitalmars-d-learn
On Monday, 20 July 2020 at 22:05:35 UTC, WhatMeWorry wrote: 1) The D Language Reference says: "There are four kinds of arrays..." with the first example being "type* Pointers to data" and "int* p; etc. At the risk of sounding overly nitpicky, isn't a pointer to an integer simply a

Re: miscellaneous array questions...

2020-07-21 Thread IGotD- via Digitalmars-d-learn
On Tuesday, 21 July 2020 at 13:23:32 UTC, Adam D. Ruppe wrote: But the array isn't initialized in the justification scenario. It is accessed through a null pointer and the type system thinks it is fine because it is still inside the static limit. At run time, the cpu just sees access to

Re: miscellaneous array questions...

2020-07-21 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/21/20 8:34 AM, Adam D. Ruppe wrote: The others aren't wrong about stack size limits playing some role, but the primary reason is that it is a weird hack for @safe, believe it or not. ... I don't recall exactly when this was discussed but it came up in the earlier days of @safe, I'm

Re: miscellaneous array questions...

2020-07-21 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 21 July 2020 at 13:16:44 UTC, IGotD- wrote: Either the array will hit that page during initialization or something else during the execution. But the array isn't initialized in the justification scenario. It is accessed through a null pointer and the type system thinks it is fine

Re: miscellaneous array questions...

2020-07-21 Thread IGotD- via Digitalmars-d-learn
On Tuesday, 21 July 2020 at 12:34:14 UTC, Adam D. Ruppe wrote: With the null `a`, the offset to the static array is just 0 + whatever and the @safe mechanism can't trace that. So the arbitrary limit was put in place to make it more likely that such a situation will hit a protected page and

Re: miscellaneous array questions...

2020-07-21 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 20 July 2020 at 22:05:35 UTC, WhatMeWorry wrote: How does that pertain to an array? C arrays work as pointers to the first element and D can use that style too. 2) "The total size of a static array cannot exceed 16Mb" What limits this? The others aren't wrong about stack size

Re: miscellaneous array questions...

2020-07-21 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/21/20 7:10 AM, IGotD- wrote: On Monday, 20 July 2020 at 22:05:35 UTC, WhatMeWorry wrote: 2) "The total size of a static array cannot exceed 16Mb" What limits this? And with modern systems of 16GB and 32GB, isn't 16Mb excessively small?   (an aside: shouldn't that be 16MB in the

Re: miscellaneous array questions...

2020-07-21 Thread wjoe via Digitalmars-d-learn
On Monday, 20 July 2020 at 22:05:35 UTC, WhatMeWorry wrote: 2) "The total size of a static array cannot exceed 16Mb" What limits this? And with modern systems of 16GB and 32GB, isn't 16Mb excessively small? (an aside: shouldn't that be 16MB in the reference instead of 16Mb? that is, Doesn't

Re: miscellaneous array questions...

2020-07-21 Thread IGotD- via Digitalmars-d-learn
On Monday, 20 July 2020 at 22:05:35 UTC, WhatMeWorry wrote: 2) "The total size of a static array cannot exceed 16Mb" What limits this? And with modern systems of 16GB and 32GB, isn't 16Mb excessively small? (an aside: shouldn't that be 16MB in the reference instead of 16Mb? that is,

Re: miscellaneous array questions...

2020-07-21 Thread Ali Çehreli via Digitalmars-d-learn
On 7/20/20 8:16 PM, a...@a.com wrote: >> 3) Lastly, In the following code snippet, is arrayA and arrayB both >> allocated on the stack? arrayA is allocated on thread-local storage and lives as long as the program is active. I guess a final interaction with it can be in a 'static ~this()' or a

Re: miscellaneous array questions...

2020-07-20 Thread a--- via Digitalmars-d-learn
On Monday, 20 July 2020 at 22:05:35 UTC, WhatMeWorry wrote: 1) The D Language Reference says: "There are four kinds of arrays..." with the first example being "type* Pointers to data" and "int* p; etc. At the risk of sounding overly nitpicky, isn't a pointer to an integer simply a