[Issue 4251] Hole in the type system: Base type reference can be assigned to subtype reference (Super* is treated as a supertype of Sub*)
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Nov 17 12:00:50 PST 2011
http://d.puremagic.com/issues/show_bug.cgi?id=4251
timon.gehr at gmx.ch changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |timon.gehr at gmx.ch
Summary|Hole in the const system: |Hole in the type system:
|immutable values can be |Base type reference can be
|overwritten (const(T) is |assigned to subtype
|appendable to const(T)[]) |reference (Super* is
| |treated as a supertype of
| |Sub*)
--- Comment #16 from timon.gehr at gmx.ch 2011-11-17 11:59:55 PST ---
Class references have the same problem.
class A{}
class B:A{}
void main(){
B x;
A* y=&x; // bad!
*y=new A;
Object o = x;
assert(o is x && o && is(typeof(x)==B) && !cast(B)o);
}
I have generalized the title accordingly.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list