Thread overview
[Issue 5327] New: Immutable correctness is broken
Dec 06, 2010
SHOO
[Issue 5327] Creating new struct with literal bypasses immutability of members of members of the struct
Dec 07, 2010
Stewart Gordon
Jun 12, 2011
Walter Bright
December 06, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=5327

           Summary: Immutable correctness is broken
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: zan77137@nifty.com


--- Comment #0 from SHOO <zan77137@nifty.com> 2010-12-06 03:53:59 PST ---
This code shouldn't work:
------------------------------
import std.stdio;
struct ID
{
    immutable int value;
}

struct Data
{
    ID id;
}
void main()
{
    Data data = Data(ID(1));
    immutable int* val = &data.id.value;
    writeln(*val); // 1
    data = Data(ID(2)); // <- This line shouldn't be allowed.
    writeln(*val); // 2
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
December 07, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=5327


Stewart Gordon <smjg@iname.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |accepts-invalid, spec
                 CC|                            |smjg@iname.com
             Blocks|                            |2573
            Summary|Immutable correctness is    |Creating new struct with
                   |broken                      |literal bypasses
                   |                            |immutability of members of
                   |                            |members of the struct


--- Comment #1 from Stewart Gordon <smjg@iname.com> 2010-12-07 04:07:26 PST ---
There are several bugs that match the summary line you had.  See issue 2573.

This is closely related to issue 2625.  The solution is given in issue 2625 comment 4.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
June 12, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5327


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla@digitalmars.com
         Resolution|                            |FIXED


--- Comment #2 from Walter Bright <bugzilla@digitalmars.com> 2011-06-11 20:17:15 PDT ---
https://github.com/D-Programming-Language/dmd/commit/365297878c11039944be5d78d57909564bef70aa

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