[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 12:08:10 UTC 2024


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

Bastiaan Veelo <Bastiaan at Veelo.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |Bastiaan at Veelo.net

--- Comment #2 from Bastiaan Veelo <Bastiaan at Veelo.net> ---
I argue that it should be made an error to define an initializer of a
non-shared non-static field that allocates. Thread:
https://forum.dlang.org/post/ogvubzgprghefclgluce@forum.dlang.org

If you *want* the array to be shared across all instances, the field should be
declared `shared static`.

In https://forum.dlang.org/post/t7vm2o$p4q$1@digitalmars.com, Steven notes that
the array is shared among different threads, even, as discovered in
https://issues.dlang.org/show_bug.cgi?id=2947.

--


More information about the Digitalmars-d-bugs mailing list