Arrays and struct assignment, pt. 2

Etienne Cimon via Digitalmars-d digitalmars-d at puremagic.com
Sat Aug 1 20:18:57 PDT 2015


On Sunday, 2 August 2015 at 02:49:03 UTC, Jonathan M Davis wrote:
> On Sunday, 2 August 2015 at 01:50:50 UTC, David Nadlinger wrote:
>> Again, am I missing something obvious here? I can't quite 
>> believe that struct lifetime would have been quite as broken 
>> for so long.
>
> I suspect that what it comes down to is that opAssign doesn't 
> get used all that frequently. Most structs simply don't need 
> it, so code which would hit the bug probably isn't all that 
> common. Obviously, such code exists, but it requires using both 
> opAssign and then putting those structs in arrays - and then 
> catching the resulting bug (which you would hope would happen, 
> but if the difference is subtle enough, it wouldn't necessarily 
> be caught). And if structs with opAssign normally also define a 
> postblit, then it's that much less likely that the problem 
> would be hit.
>
> - Jonathan M Davis

I couldn't get reference counted types to work as struct members, 
for some hard-to-track reason, and am actively avoiding it right 
now as a result. Maybe we've found a cause here? The might be a 
lot of people like me that gave up trying to track it, and are 
simply avoiding error-prone uses of structs.


More information about the Digitalmars-d mailing list