Why am I getting segfaults when doing `foreach` with arrays of references?

Liam McGillivray yoshi.pit.link.mario at gmail.com
Sat Mar 9 09:05:59 UTC 2024


On Saturday, 9 March 2024 at 07:49:52 UTC, Liam McGillivray wrote:
> But that begs the question; why? Don't dynamic arrays always 
> start with a length of 0? If the array was only extended when 
> valid objects were appended using the append operator `~=`, and 
> none of those objects were deleted (as I the destructor was 
> never called), why would some of the array elements be null?

I'll answer my own question; because the thing assigned to the 
array was already null.

Anyway, I managed to fix the segfaults. In the latest two 
commits, I have turned some pointers into references. Now that I 
understand this, I should have fewer segmentation faults.


More information about the Digitalmars-d-learn mailing list