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


--- Comment #0 from timon.gehr gmx.ch 2013-08-04 16:01:37 PDT ---
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


--- Comment #1 from Kenji Hara <k.hara.pg gmail.com> 2013-08-07 23:16:26 PDT ---
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



--- Comment #2 from github-bugzilla puremagic.com 2013-08-18 16:40:58 PDT ---
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                       |


--- Comment #3 from timon.gehr gmx.ch 2013-08-19 03:06:54 PDT ---
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



--- Comment #4 from Kenji Hara <k.hara.pg gmail.com> 2013-08-20 19:42:48 PDT ---
(In reply to comment #3)
 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



--- Comment #5 from github-bugzilla puremagic.com 2013-08-27 13:18:03 PDT ---
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
Merge pull request #2487 from 9rnsr/fix_inout

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