[Issue 19668] calling a function causes crash - frame pointer access error can be bypassed with typeof(this).init
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Feb 11 18:51:35 UTC 2019
https://issues.dlang.org/show_bug.cgi?id=19668
--- Comment #1 from Ali Ak <ali.akhtarzada at gmail.com> ---
Actually you don't need a static func. This crashes:
struct S(alias fun) {
auto call(Args...)(Args args) {
return fun(args);
}
}
auto construct(alias fun)() {
auto a = S!fun.init; // 1
return a;
}
void main() {
int count = 0;
auto func() { return count++; }
auto s = construct!func;
s.call(); // crashes
}
And if you change @1 to "auto a = S!fun();" then all is well.
--
More information about the Digitalmars-d-bugs
mailing list