Re: Static array initialisation

2021-04-01 Thread Ali Çehreli via Digitalmars-d-learn
On 4/1/21 2:30 AM, DLearner wrote: > immutable uint MemSize=100; // Memory size in bytes. > ubyte[MemSize] MemPool = 8; // Initialised to 8 for debugging. Valid index values there are from 0 to 99, inclusive. > WkPtr = [0]; > > counter = 1; > while (counter <= 102) { >

Re: Static array initialisation

2021-04-01 Thread user1234 via Digitalmars-d-learn
On Thursday, 1 April 2021 at 09:30:28 UTC, DLearner wrote: On Wednesday, 31 March 2021 at 23:21:59 UTC, russhy wrote: On Wednesday, 31 March 2021 at 17:54:38 UTC, DLearner wrote: [...] Can you show the print function? Maybe the problem lies there? Using rdmd, I believe the code below

Re: Static array initialisation

2021-04-01 Thread DLearner via Digitalmars-d-learn
On Wednesday, 31 March 2021 at 23:21:59 UTC, russhy wrote: On Wednesday, 31 March 2021 at 17:54:38 UTC, DLearner wrote: On Wednesday, 31 March 2021 at 17:46:25 UTC, Imperatorn wrote: On Wednesday, 31 March 2021 at 17:27:44 UTC, DLearner wrote: Hi I did: immutable uint MemSize=100; //

Re: Static array initialisation

2021-04-01 Thread Imperatorn via Digitalmars-d-learn
On Wednesday, 31 March 2021 at 17:27:44 UTC, DLearner wrote: Hi I did: immutable uint MemSize=100; // Memory size in bytes. // Memory Pool ubyte[MemSize] MemPool = 8; And had a look in memory. I think the compiler set up 101 '8's, not 100 in memory. Which I did not expect. Best

Re: Static array initialisation

2021-03-31 Thread russhy via Digitalmars-d-learn
On Wednesday, 31 March 2021 at 17:54:38 UTC, DLearner wrote: On Wednesday, 31 March 2021 at 17:46:25 UTC, Imperatorn wrote: On Wednesday, 31 March 2021 at 17:27:44 UTC, DLearner wrote: Hi I did: immutable uint MemSize=100; // Memory size in bytes. // Memory Pool ubyte[MemSize]

Re: Static array initialisation

2021-03-31 Thread Steven Schveighoffer via Digitalmars-d-learn
On 3/31/21 2:03 PM, DLearner wrote: On Wednesday, 31 March 2021 at 18:00:32 UTC, Steven Schveighoffer wrote: The answer is no, the compiler does not write to memory beyond the 100 elements. That memory *might* happen to have an 8 in there. That's not proof of anything though. I entirely

Re: Static array initialisation

2021-03-31 Thread DLearner via Digitalmars-d-learn
On Wednesday, 31 March 2021 at 18:00:32 UTC, Steven Schveighoffer wrote: On 3/31/21 1:54 PM, DLearner wrote: On Wednesday, 31 March 2021 at 17:46:25 UTC, Imperatorn wrote: On Wednesday, 31 March 2021 at 17:27:44 UTC, DLearner wrote: Hi I did:    immutable uint  MemSize=100;  // Memory size

Re: Static array initialisation

2021-03-31 Thread Steven Schveighoffer via Digitalmars-d-learn
On 3/31/21 1:54 PM, DLearner wrote: On Wednesday, 31 March 2021 at 17:46:25 UTC, Imperatorn wrote: On Wednesday, 31 March 2021 at 17:27:44 UTC, DLearner wrote: Hi I did:    immutable uint  MemSize=100;  // Memory size in bytes. // Memory Pool    ubyte[MemSize]  MemPool = 8; And had a look

Re: Static array initialisation

2021-03-31 Thread DLearner via Digitalmars-d-learn
On Wednesday, 31 March 2021 at 17:46:25 UTC, Imperatorn wrote: On Wednesday, 31 March 2021 at 17:27:44 UTC, DLearner wrote: Hi I did: immutable uint MemSize=100; // Memory size in bytes. // Memory Pool ubyte[MemSize] MemPool = 8; And had a look in memory. I think the compiler set up

Re: Static array initialisation

2021-03-31 Thread Imperatorn via Digitalmars-d-learn
On Wednesday, 31 March 2021 at 17:27:44 UTC, DLearner wrote: Hi I did: immutable uint MemSize=100; // Memory size in bytes. // Memory Pool ubyte[MemSize] MemPool = 8; And had a look in memory. I think the compiler set up 101 '8's, not 100 in memory. Which I did not expect. Best