http://d.puremagic.com/issues/show_bug.cgi?id=4251
--- Comment #18 from Steven Schveighoffer <[email protected]> 2011-11-18 07:10:20 PST --- (In reply to comment #17) > (In reply to comment #16) > > B x; > > A* y=&x; // bad! > Everything you describe is supposed to happen. "A* y = &x" is the point of > inheritance. What exactly is the problem you see in the above? All of your > assert elements seem fine too… The example isn't illustrative enough. Here's a better example: class A {} class B : A {void foo() {writeln("hello, B");} } void main() { B x; A* y = &x; *y = new A; x.foo(); // boom! Call to invalid vtable entry } As I said in an earlier comment, this bug is really a dup of bug 2095, but it adds a different twist. If we want to consolidate, we should close this as a duplicate of 2095. > Reverting title. This bug is about the const safety design of the language, > not > about inheritance. Even if there is a problem with inheritance, it should be a > separate bug unless you can argue they have the same cause. It's somewhat the same thing. const(T) is really a "base class" of T, since T implicitly casts to const(T), but const(T) doesn't implicitly cast to T. I won't revert the bug description again, because I think this case is already covered in 2095. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
