digitalmars.D.bugs - [Issue 15866] New: casting away const from "super" results in "this"
- via Digitalmars-d-bugs (33/33) Apr 03 2016 https://issues.dlang.org/show_bug.cgi?id=15866
https://issues.dlang.org/show_bug.cgi?id=15866 Issue ID: 15866 Summary: casting away const from "super" results in "this" Product: D Version: D2 Hardware: x86_64 OS: Windows Status: NEW Keywords: wrong-code Severity: normal Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: r.sagitario gmx.de class A { int foo(bool) { return 'a'; } } class B : A { override int foo(bool b) const { return b ? 'b' : (cast()super).foo(b); } } void main() { B b = new B; assert(b.foo(false) == 'a'); } This code causes a stack overflow because (cast()super).foo(b) calls B.foo, not A.foo. I've found this pattern while debugging something else in OutOfMemoryError.toString. It is also used in std.xml.Document.toHash, so maybe issue 14966 is related. --
Apr 03 2016