www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 2780] New: ref Return Allows modification of immutable data

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2780

           Summary: ref Return Allows modification of immutable data
           Product: D
           Version: 2.027
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Keywords: accepts-invalid
          Severity: regression
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: dsimcha yahoo.com


import std.stdio;

struct Immutable {
    immutable uint[2] num;

    ref uint opIndex(uint index) immutable {
        return num[index];
    }
}

void main() {
    immutable Immutable foo;
    writeln(foo[0]);  // Prints 0.
    foo[0]++;
    writeln(foo[0]);  // Prints 1.
}

Probably related to the fix for bug 2728 because the weird error message
provided by 2728 was what used to prevent this bug from happening.


-- 
Apr 01 2009
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2780


Kenji Hara <k.hara.pg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |k.hara.pg gmail.com
         Resolution|                            |DUPLICATE


--- Comment #1 from Kenji Hara <k.hara.pg gmail.com> 2011-06-17 02:59:15 PDT ---
*** This issue has been marked as a duplicate of issue 2521 ***

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