[Issue 4923] immutable module variables are modifiable in non-shared module constructors

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Jan 4 00:28:20 PST 2011


http://d.puremagic.com/issues/show_bug.cgi?id=4923


Jonathan M Davis <jmdavisProg at gmx.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jmdavisProg at gmx.com


--- Comment #3 from Jonathan M Davis <jmdavisProg at gmx.com> 2011-01-04 00:26:06 PST ---
immutable variables are implicitly shared. That's part of the point of
immutable after all. And given that fact, allowing the initializing of
immutable variables in non-shared static constructors is definitely a bug. If
we decided that immutable variables were _not_ implicitly shared and made it so
that they weren't, then that would fix the problem, but that would on some
level defeat the purpose of immutable. So, if we are going to have immutable
variables be implicitly shared, then I propose that we disallow the
initializing of immutable variables with global scope in non-shared static
constructors. That is, all global variables and static variables which are
immutable _must_ be initialized in shared static constructors. The non-static
local variables would be okay (and I'm not sure that those actually end up
being implicitly shared anyway), since they'd be re-created on each function
call, but any immutable variable which could be initialized in a static
constructor would have to be initialized in a shared static constructor. I
don't really see any other viable way to fix this bug if we're going to
continue to have immutable variables be implicitly shared.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list