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

When I look there are 100. What makes you think there are 101?

I printed bytes from &MemPool[0] to just beyond &MemPool[99}.

When you look beyond the bounds of where you have access to, you are bound to see just about anything.

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.

-Steve

I entirely agree - I wasn't saying anything was wrong, but I _was_ surprised. Not least because it's not chance, I changed the initial value and the effect repeated with the new value.

Reply via email to