digitalmars.D.bugs - [Issue 9653] New: Wrong implicit cast allowed with inheritance
- d-bugmail puremagic.com (34/34) Mar 05 2013 http://d.puremagic.com/issues/show_bug.cgi?id=9653
- d-bugmail puremagic.com (20/20) Jul 28 2013 http://d.puremagic.com/issues/show_bug.cgi?id=9653
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 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: -------
Mar 05 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 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: -------
Jul 28 2013