[Issue 24324] A default-initialized variable is not identical to its init value when it contains a default-initialized member variable that is a dynamic array

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Jan 8 18:05:22 UTC 2024


https://issues.dlang.org/show_bug.cgi?id=24324

--- Comment #3 from Jonathan M Davis <issues.dlang at jmdavisProg.com> ---
(In reply to RazvanN from comment #1)
> A consequence of this is that `assert(S.init is S.init)` fails in this case.
> Which is kind of absurd. However, I would argue that when dynamic arrays are
> involved the backend is free to do whatever it sees fit with regards to the
> addresses of dynamic arrays, so using `is` in this case (as opposed to
> opEquals) is brittle.

My expectation is that 

SomeStruct s;
assert(s is SomeStruct.init);

will pass for every type, and IMHO, if it doesn't, we should rethink what we're
doing.

--


More information about the Digitalmars-d-bugs mailing list