Thread overview
[Issue 5284] New: Array ops punch through const system
Nov 28, 2010
Sobirari Muhomori
Nov 28, 2010
Sobirari Muhomori
Jun 25, 2011
Walter Bright
November 28, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=5284

           Summary: Array ops punch through const system
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Keywords: accepts-invalid
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: dfj1esp02@sneakemail.com
            Blocks: 2573


--- Comment #0 from Sobirari Muhomori <dfj1esp02@sneakemail.com> 2010-11-28 09:00:08 PST ---
---
class A { int m=5; }

int main()
{
    A[] a=new A[1];
    immutable(A)[] b=[new immutable(A)];
    assert(b[0].m==5);
    a[]=b[]; //should not pass typecheck
    a[0].m=10;
    assert(b[0].m==5,"fail"); //line 18
    return 0;
}
---
>dmd -w -debug -run test.d
---
core.exception.AssertError@test.d(18): fail

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



--- Comment #1 from Sobirari Muhomori <dfj1esp02@sneakemail.com> 2010-11-28 09:13:10 PST ---
Interesting...
---
class A { int m=5; }

int main()
{
    A[] a=new A[1];
    int[] b=[0];
    a[]=b[];
    return 0;
}
---
this code gives error: cannot implicitly convert expression (b[]) of type int[]
to const(A[]). Seems like the compiler tries to cast right-hand expression to
const(typeof(left-hand expression)), then proceeds with copying.

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


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-25 11:53:21 PDT ---
https://github.com/D-Programming-Language/dmd/commit/d4086972a1456f36175e242ea9ab6165f96592b1

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