Bug 20559 – Reference type + alias this + AA + AA.clear causes SEGV

Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2020-02-03T18:24:12Z
Last change time
2020-02-04T00:02:39Z
Keywords
pull
Assigned to
No Owner
Creator
Mathias LANG

Comments

Comment #0 by pro.mathias.lang — 2020-02-03T18:24:12Z
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
Comment #1 by dlang-bot — 2020-02-03T18:38:09Z
@Geod24 created dlang/druntime pull request #2927 "Fix issue 20559: AA.clear segfault when used with alias this" fixing this issue: - Fix issue 20559: AA.clear segfault when used with alias this https://github.com/dlang/druntime/pull/2927
Comment #2 by dlang-bot — 2020-02-04T00:02:39Z
dlang/druntime pull request #2927 "Fix issue 20559: AA.clear segfault when used with alias this" was merged into stable: - 261124ff0aeb6ac577421045e7fa99f261796316 by Geod24: Fix issue 20559: AA.clear segfault when used with alias this https://github.com/dlang/druntime/pull/2927