Static array initialisation

user1234 user1234 at 12.de
Thu Apr 1 09:40:37 UTC 2021


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 demonstrates the situation.
>
> import std.stdio;
> void main() {
>    immutable uint  MemSize=100;  // Memory size in bytes.
>    uint counter;
>    uint idx;
>    ubyte* WkPtr;
>    ubyte WkUbyte;
>
> // Memory Pool
>    ubyte[MemSize]  MemPool = 8;  // Initialised to 8 for 
> debugging.
>
>    WkPtr = &MemPool[0];
>
>    counter = 1;
>    while (counter <= 102) {
>
>       idx = counter - 1;
> 	
> 	  WkUbyte = *(WkPtr + idx);
>
>       writeln("idx = ", idx, "WkUbyte = ", WkUbyte);
>
>       counter = counter + 1;
>    }
> }

memset would fill a whole page even if the specified size is in 
the middle of a page. Try with 64, 4096 for example, instead of 
100.


More information about the Digitalmars-d-learn mailing list