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 = &MemPool[0]; > > counter = 1; > while (counter <= 1

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 demon

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; // Mem

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 rega

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] MemPoo

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 agr

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 in

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 in

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 rega

Static array initialisation

2021-03-31 Thread DLearner via Digitalmars-d-learn
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 regards