digitalmars.D.bugs - [Issue 20559] New: Reference type + alias this + AA + AA.clear
- d-bugmail puremagic.com (34/35) Feb 03 2020 https://issues.dlang.org/show_bug.cgi?id=20559
https://issues.dlang.org/show_bug.cgi?id=20559 Issue ID: 20559 Summary: Reference type + alias this + AA + AA.clear causes SEGV Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: major Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: pro.mathias.lang gmail.com Test code: ``` import std.stdio; class Bar { int[string] aa; alias aa this; } void main () { scope b = new Bar; b["Hello"] = 42; b.clear; // SEGV happens here, next line is never reached writeln("Oopsie"); } ``` This happens because 'clear' is defined as:void clear(T : Value[Key], Value, Key)(T aa)And the code just blindly casts T to a `struct AA`: https://github.com/dlang/druntime/blob/1049bb806679436103f8174c1f77541d5ad99091/src/object.d#L2167-L2170 --
Feb 03 2020