April 10, 2017 [Issue 17315] New: Assigning a delegate to a function compiles but causes segfault | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=17315 Issue ID: 17315 Summary: Assigning a delegate to a function compiles but causes segfault Product: D Version: D2 Hardware: All URL: http://dlang.org/ OS: All Status: NEW Severity: major Priority: P3 Component: dmd Assignee: nobody@puremagic.com Reporter: tomerfiliba@gmail.com using `DMD64 D Compiler v2.073.0` on ubuntu 16.04 =========================================== class Base { __gshared static Base function()[string] registry; static Base load(string name) {return registry[name]();} } class Child: Base { shared static this() { import std.traits: fullyQualifiedName; registry[fullyQualifiedName!(typeof(this))] = &_load; // <<< this shouldn't compile } Base _load() {return new typeof(this);} } void main() { auto inst = Base.load("dtest.Child"); // segfault } =========================================== Program received signal SIGSEGV, Segmentation fault. 0x0000000000453f4a in invariant._d_invariant(Object) () (gdb) bt #0 0x0000000000453f4a in invariant._d_invariant(Object) () #1 0x0000000000440272 in dtest.Child._load() (this=0x477d7b <_TMP1+11>) at src/dtest.d:69 #2 0x00000000004401ad in dtest.Base.load(immutable(char)[]) (name=...) at src/dtest.d:60 #3 0x000000000044029c in D main () at src/dtest.d:81 =========================================== if i make `_load` a static function (as it should be), everything works as expected class Child: Base { ... static Base _load() {return new typeof(this);} } -- |
Copyright © 1999-2021 by the D Language Foundation