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

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


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

Jakob Ovrum <jakobovrum at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakobovrum at gmail.com

--- Comment #7 from Jakob Ovrum <jakobovrum at gmail.com> ---
(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
}

--


More information about the Digitalmars-d-bugs mailing list