Debug help - Programming in D - extending tail slice terminates sharing unexpectedly. Page 69, 70

Steven Schveighoffer schveiguy at gmail.com
Mon Oct 20 14:43:05 UTC 2025


On Sunday, 19 October 2025 at 20:44:39 UTC, Brother Bill wrote:

> Console output:
> ```
> slice: [1, 3, 5, 7, 9, 11, 13, 15, 17] length: 9 capacity: 11
>
> slice: [1, 3, 5, 7, 9, 11, 13, 15, 17] length: 9 capacity: 11
> tailSlice: [9, 11, 13, 15, 17] length: 5 capacity: 7 
> &tailSlice[0]: 26AAAA31040
> tailSlice after incrementing length by 1: [9, 11, 13, 15, 17, 
> 0] length: 6 capacity: 11 &tailSlice[0]: 26AAAA31060
> After tail slice length increase and changing tailSlice[0] to 
> 888.  length: 6 capacity: 11
> tailSlice: [888, 11, 13, 15, 17, 0]
> slice    : [1, 3, 5, 7, 9, 11, 13, 15, 17]
>
> ```

This is a bug, introduced in 2.111.0

If you use 2.110.0 you will get the expected behavior.

-Steve


More information about the Digitalmars-d-learn mailing list