January 22, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7343

           Summary: hole in the type system: inout function call compiles
                    but shouldn't
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: accepts-invalid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: timon.gehr@gmx.ch


--- Comment #0 from timon.gehr@gmx.ch 2012-01-21 17:13:12 PST ---
DMD 2.057:

import std.stdio;
inout(int)** qux(inout(int) p, inout(int)** pp){
    return pp;
}
void main(){
    immutable(int) x;
    immutable(int)* y = &x;
    int z;
    *qux(1,&y)=&z; // BOOM.

    writeln(is(typeof(&z)==int*)            &&
            is(typeof( y)==immutable(int)*) &&
            &z is y); // "true"
}

The code exploits the fact that inout matching does not check sanity, in order
to perform the forbidden immutable(int)** => const(int)** conversion. The code
could be slightly modified such that it performs an int** => const(int)**
conversion instead.

(Ideally, inout would be deduced as immutable in this specific example and the assignment would cause an error.)

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 22, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7343


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

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


--- Comment #1 from Kenji Hara <k.hara.pg@gmail.com> 2012-01-22 05:33:18 PST ---
This issue was recently fixed in 2.058head, by merging https://github.com/D-Programming-Language/dmd/pull/558 .

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