On 6/7/18 6:58 PM, DigitalDesigns wrote:
On Thursday, 7 June 2018 at 21:57:17 UTC, Steven Schveighoffer wrote:
On 6/7/18 5:07 PM, DigitalDesigns wrote:
class A;
class B
{
A a = new A();
}
auto b1 = new B();
auto b2 = new B();
assert(b1.a == b2.a)!!
Yep, long-standing issue: https://issues.dlang.org/show_bug.cgi?id=2947
Almost a decade old!
wait! everyone is saying it is a feature! So, which is it, a feature or
a bug?!?!?
It's a feature that you can assign a static initializer to a class or
struct member and have that work at compile time (using CTFE).
But when it's a reference to mutable data, it's a bug. Just the idea
that you have implicitly shared data if you create instances in multiple
threads should make it obviously a bug.
Even back then it was a debate, look at the bug report. But it's
definitely a bug. Just hard to close since it will probably break a lot
of code.
-Steve