March 06, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9653

           Summary: Wrong implicit cast allowed with inheritance
           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: k.hara.pg@gmail.com


--- Comment #0 from Kenji Hara <k.hara.pg@gmail.com> 2013-03-05 16:53:33 PST ---
C1.foo correctly reports error with wrong implicit conversion from TypeInfo to inout(TypeInfo), but C2.foo doesn't.

class B {
    inout(TypeInfo) foo() nothrow pure inout {
        return null;
    }
}
class C1 {
    /*override*/ inout(TypeInfo) foo() inout {
        return typeid(Object);  // error, correct
    }
}
class C2 : B {
    override inout(TypeInfo) foo() inout {
        return typeid(Object);  // no error, BUG
    }
}

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


Henning Pohl <henning@still-hidden.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |henning@still-hidden.de


--- Comment #1 from Henning Pohl <henning@still-hidden.de> 2013-07-28 14:14:44 PDT ---
Reduced:

class C {
    inout(TypeInfo) foo() pure inout {
        return typeid(Object);
    }
}

The problem is that by using typeid(Object) you can get access to a global class instance (TypeInfo) in a pure function. And the result of pure functions can be casted to be inout. But in this case you didn't create the class instance by yourself. So only self-created TypeInfo-instances should be allowed to get casted. These are hard to detect though.

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