[Issue 2947] Array literal changeable if part of class.

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Sat Dec 5 08:33:17 PST 2015


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

--- Comment #8 from yebblies <yebblies at gmail.com> ---
(In reply to Jakob Ovrum from comment #7)
> (In reply to Georg Wrede from comment #0)
> > ...
> 
> Member field initializers are always evaluated at compile-time so this
> behaviour is not a bug. The bug is that the array elements are allocated in
> global memory instead of TLS. Only `immutable` and `shared` elements should
> be allocated in global memory. We can also do it for `const` elements as
> CTFE should always be pure enough to assume uniqueness.
> 
> Same issue as CT initializers of mutable class type, i.e.
> 
> void main()
> {
>     static Object o = new Object; // stored in global memory; should be TLS
> }

How exactly would putting the array in TLS fix this bug?

--


More information about the Digitalmars-d-bugs mailing list