[Issue 3621] New: implicit conversion to const rules need tightening

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Dec 16 13:28:10 PST 2009


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

           Summary: implicit conversion to const rules need tightening
           Product: D
           Version: 2.036
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: bugzilla at digitalmars.com


--- Comment #0 from Walter Bright <bugzilla at digitalmars.com> 2009-12-16 13:28:09 PST ---
The following allows a write to an immutable array:

import std.stdio;

void doSomething(const(char)[][] a, const(char)[][] b)
{
    a[0]=b[0];
}

void main()
{
    string s = "hello";
    char[][1] a;
    string[1] b;
    b[0] = s;
    doSomething(a, b);
    a[0][1] = 'c';   // OOPS!
    writeln(s);
}

So, a conversion to const that is not the top ref should be disallowed.

-- 
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