Thread overview
[Issue 10376] Mutable field initializer reference is accessible through immutable aggregate
[Issue 10376] Glaring hole in const system
Oct 21, 2015
Jonathan M Davis
Mar 30
Dlang Bot
June 13, 2015
https://issues.dlang.org/show_bug.cgi?id=10376

secondaryAccount@web.de changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |secondaryAccount@web.de

--- Comment #4 from secondaryAccount@web.de ---
This seems to be a general problem with default initialised variables, not only
arrays declared classes:
http://forum.dlang.org/thread/vimknyxvoagcmmwmzdnb@forum.dlang.org#post-klfhepckofdbsakmjafq:40forum.dlang.org

still valid issue with 2.067.

--
October 21, 2015
https://issues.dlang.org/show_bug.cgi?id=10376

Andrei Alexandrescu <andrei@erdani.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrei@erdani.com

--- Comment #5 from Andrei Alexandrescu <andrei@erdani.com> ---
The quickest way to stop the bleeding is to disallow the code. It's incorrect for immutable data and misleading for mutable data. (What an user might expect is that each data comes with a distinct array.)

--
October 21, 2015
https://issues.dlang.org/show_bug.cgi?id=10376

Jonathan M Davis <issues.dlang@jmdavisProg.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |issues.dlang@jmdavisProg.co
                   |                            |m

--- Comment #6 from Jonathan M Davis <issues.dlang@jmdavisProg.com> ---
This should be legal if the member variable is initialized with an immutable value, since that doesn't create any holes in the type system. In fact, if it weren't for issue# 12624, SysTime would have a default value for its timezone which was immutable (with timezone being Rebindable!(immutable TimeZone) ). But of course that requires that the member variable either be immutable or something like Rebindable, immutable(T)*, or immutable(T)[] which can point/refer to an immutable value but is not itself immutable.

However, it's definitely the case that this should be disallowed when the initializer is mutable, and while it _could_ work with a const initializer under some set of circumstances, it's way simpler to just disallow it.

--
March 18
https://issues.dlang.org/show_bug.cgi?id=10376

Nick Treleaven <nick@geany.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |safe
                 CC|                            |nick@geany.org
            Summary|Glaring hole in const       |Mutable field initializer
                   |system                      |reference is accessible
                   |                            |through immutable aggregate

--
March 30
https://issues.dlang.org/show_bug.cgi?id=10376

Dlang Bot <dlang-bot@dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull

--- Comment #7 from Dlang Bot <dlang-bot@dlang.rocks> ---
@ntrel updated dlang/dmd pull request #16347 "Require @system for field initializers with mutable reference types" fixing this issue:

- Require @system for field initializers with mutable reference types

  Enabled with -preview=unsafeFieldInit.

  Fixes Bugzilla 10376 - Mutable field initializer reference is accessible
through immutable aggregate

https://github.com/dlang/dmd/pull/16347

--
June 06
https://issues.dlang.org/show_bug.cgi?id=10376

Nick Treleaven <nick@geany.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|                            |https://issues.dlang.org/sh
                   |                            |ow_bug.cgi?id=2947

--
June 07
https://issues.dlang.org/show_bug.cgi?id=10376

Nick Treleaven <nick@geany.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |john.loughran.colvin@gmail.
                   |                            |com

--- Comment #8 from Nick Treleaven <nick@geany.org> ---
*** Issue 15612 has been marked as a duplicate of this issue. ***

--