www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 9461] New: Ability to break typesystem with `inout`

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

           Summary: Ability to break typesystem with `inout`
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: accepts-invalid
          Severity: critical
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: verylonglogin.reg gmail.com


--- Comment #0 from Denis Shelomovskij <verylonglogin.reg gmail.com> 2013-02-06
15:17:44 MSK ---
Implicit conversion from `inout(<derived class>)[]` to `inout(<base class>)[]`
must not be allowed (just like for unqualified case) as `inout` can be `<no
qualifier>` (i.e. mutable):
---
class A { }
class B: A { }

inout(A)[] getBArrayAsAArray(inout(B)[] bArr)
{ return bArr; }

void main()
{
    B[] bArr = [new B()];
    getBArrayAsAArray(bArr)[0] = new A(); // bArr[0] not a `B` any more...
}
---

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 06 2013
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9461



--- Comment #1 from Kenji Hara <k.hara.pg gmail.com> 2013-02-06 19:57:28 PST ---
Similar problem exists in:
- AA key conversion
- AA value conversioin
- Pointer target conversion
- static to dynamic array conversion

But, bare class conversion inout(B) to inout(A) still be allowed.

Test case: 
----
class A {}
class B : A {}

void conv1(inout(B)[]      x) { inout(A)[]    y = x; }  // should be NG
void conv2(int[inout(B)]   x) { int[inout(A)] y = x; }  // should be NG
void conv3(inout(B)[int]   x) { inout(A)[int] y = x; }  // should be NG
void conv4(inout(B)*       x) { inout(A)*     y = x; }  // should be NG
void conv5(ref inout(B)[1] x) { inout(A)[]    y = x; }  // should be NG

void conv6(inout(B)        x) { inout(A)      y = x; }  // should be OK

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 06 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9461


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

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


--- Comment #2 from Kenji Hara <k.hara.pg gmail.com> 2013-02-06 20:09:13 PST ---
https://github.com/D-Programming-Language/dmd/pull/1633

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 06 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9461



--- Comment #3 from github-bugzilla puremagic.com 2013-02-17 21:49:43 PST ---
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/3241c48f8bfd1e3bd0be0ee88a9b961baf42ff93
fix Issue 9461 - Ability to break typesystem with `inout`

https://github.com/D-Programming-Language/dmd/commit/62e77c805ab01043c01da76f5a7ec3d67341399c
Merge pull request #1633 from 9rnsr/fix9461

Issue 9461 - Ability to break typesystem with `inout`

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 17 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9461


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


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