[Issue 17315] Assigning a delegate to a function compiles but causes segfault
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu May 18 10:39:55 UTC 2023
https://issues.dlang.org/show_bug.cgi?id=17315
Eyal <eyal at weka.io> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |REOPENED
CC| |eyal at weka.io
Resolution|WORKSFORME |---
--- Comment #2 from Eyal <eyal at weka.io> ---
A small change to _load to make it actually use the incorrect "this" shows it's
still broken:
import std;
class Base {
__gshared static Base function()[string] registry;
static Base load(string name) {return registry[name]();}
}
class Child: Base {
shared static this() {
registry[__traits(identifier, typeof(this))] = &_load; // <<<
this shouldn't compile
}
int x = 1;
Base _load() {
assert(x == 1, x.text); //
core.exception.AssertError at dtest.d(15): 1970086008
return new typeof(this);
}
}
void main() {
auto inst = Base.load("Child"); // segfault
}
--
More information about the Digitalmars-d-bugs
mailing list