https://d.puremagic.com/issues/show_bug.cgi?id=11714
--- Comment #8 from David Nadlinger <c...@klickverbot.at> 2013-12-12 05:51:44 PST --- (In reply to comment #7) > If I understand the logic right, the result of "new MyClass" is not knowable > at > compile time Actually it is, otherwise you'd get a "cannot be read/evaluated at compile time" error in the constructor. The issue here is that in D global variables can only be initialized with statically known data (written to the relevant sections of the object file). For everything else, you need to use a static constructor. While support for converting CTFE class instances into data blobs to write to an object file was implemented a while ago, variables of a class type are of course references and need to point somewhere. Now, if a variable is either immutable or explicitly shared between threads, that's fine, you just emit the data once and then initialize the variable to point to that. However, for mutable, thread-local data, this simple scheme doesn't work, as it would require a new instance to be created for each new thread. I didn't really think about whether it would be possible to resolve that situation by emitting all the instance data into the TLS section yet, but this certainly isn't implemented in DMD right now. Thus, initializing class references that are (potentially) modified from more than one thread with CTFE instances is disallowed. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------