Thread overview | ||||||||
---|---|---|---|---|---|---|---|---|
|
February 11, 2019 [Issue 19668] calling a function causes crash - frame pointer access error can be bypassed with typeof(this).init | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=19668 --- Comment #1 from Ali Ak <ali.akhtarzada@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. -- |
February 11, 2019 [Issue 19668] Using init instead of construction causes crash if type is parameterized on alias to function that accesses frame | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=19668 Ali Ak <ali.akhtarzada@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Summary|calling a function causes |Using init instead of |crash - frame pointer |construction causes crash |access error can be |if type is parameterized on |bypassed with |alias to function that |typeof(this).init |accesses frame -- |
January 08, 2023 [Issue 19668] Using init instead of construction causes crash if type is parameterized on alias to function that accesses frame | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=19668 Basile-z <b2.temp@gmx.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |wrong-code CC| |b2.temp@gmx.com Hardware|x86 |All OS|Mac OS X |All -- |
January 09, 2023 [Issue 19668] Using init instead of construction causes crash if type is parameterized on alias to function that accesses frame | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=19668 Nick Treleaven <nick@geany.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |nick@geany.org Resolution|--- |INVALID --- Comment #2 from Nick Treleaven <nick@geany.org> --- main.func captures a runtime variable `count` whose address is not known at compile-time. S.init must be known at compile-time. So using S.init will cause a null context pointer for func instead of one pointing to main.count. You need to call S's constructor, not use S.init. -- |
Copyright © 1999-2021 by the D Language Foundation