www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 10758] New: Unsound type checking for inout.

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

           Summary: Unsound type checking for inout.
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: timon.gehr gmx.ch



With DMD, inout can be used to coerce away immutability as follows:

int* foo(inout(int)* x) safe{
    inout(int)* screwUp(inout(int)*){ return x; }
    return screwUp((int*).init);
}

void main(){
    immutable x = 123;
    static assert(is(typeof(*&x)==immutable));
    assert(*&x==123);
    immutable(int)* y = &x;
    *foo(y)=456;
    assert(*&x==456);
    assert(x!=*&x); // (!)
}

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


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |accepts-invalid, pull



https://github.com/D-Programming-Language/dmd/pull/2455

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




Commit pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/988eae63db3be236428f7753dee0812ef6aed5ec
fix Issue 10758 - Unsound type checking for inout

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


Walter Bright <bugzilla digitalmars.com> changed:

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


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


timon.gehr gmx.ch changed:

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



The patch misses to take into consideration inout member functions. Eg. the
following function still manages to unsafely coerce its argument to mutable:

int* foo(inout(int)* x) safe{
    struct S{ inout(int)* screwUp()inout{ return x; } }
    return S().screwUp();
}

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





 The patch misses to take into consideration inout member functions. Eg. the
 following function still manages to unsafely coerce its argument to mutable:
 
 int* foo(inout(int)* x) safe{
     struct S{ inout(int)* screwUp()inout{ return x; } }
     return S().screwUp();
 }
https://github.com/D-Programming-Language/dmd/pull/2487 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Aug 20 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10758




Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/a61e407fa9fa7e20e8035f41d4c26569e06b5ed8
Additional fix issue 10758 for inout method of nested aggregate

https://github.com/D-Programming-Language/dmd/commit/0542bbb77850e65a206b625970dc8b33ff6fe2fb


Additional fix issue 10758 for inout method of nested aggregate

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


Walter Bright <bugzilla digitalmars.com> changed:

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


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