Why allow initializers of non-static members that allocate?
Bastiaan Veelo
Bastiaan at Veelo.net
Fri Jun 10 22:20:22 UTC 2022
On Friday, 10 June 2022 at 14:56:24 UTC, Steven Schveighoffer
wrote:
> On 6/10/22 3:46 AM, Mike Parker wrote:
>> I think this is a case where having a warning that's on by
>> default, and which can be explicitly disabled, is useful.
>> "Blah blah .init blah blah. See link-to-something-in-docs. Is
>> this what you intended?"
>
> Here the language is being extremely unsafe.
>
> Not only is the field shared between instances, it's shared
> across instances in *different threads*.
>
> Discovered circa 2009:
> https://issues.dlang.org/show_bug.cgi?id=2947
Thanks for the pointer. #dbugfix 2947
> It should be illegal to declare a field this way that has
> mutable references without being `shared`. End of story.
More information about the Digitalmars-d-learn
mailing list