Make toDelegate safe for function pointers#8769
Conversation
|
Thanks for your pull request and interest in making D better, @Bolpat! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please see CONTRIBUTING.md for more information. If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment. Bugzilla referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.
|
dkorpel
left a comment
There was a problem hiding this comment.
Why is there a new branch for function pointers, is the final else case obsolete now?
- $(LI Does not work with
@safefunctions.)
This line is no longer accurate now
Because |
That should have been a review comment. |
I can't comment on code not in the diff |
There's now branches for |
|
Ping @Bolpat |
1 similar comment
|
Ping @Bolpat |
|
Sorry, I was absent for a while. I looked into the failed checks and didn’t understand what’s wrong. Should I force-push? |
|
@Bolpat yes, please rebase & force-push. |
|
Also, please answer #8769 (comment) |
|
|
||
| () @trusted | ||
| { | ||
| // assigning funcptr is @system, but it’s safe here because `fp` needs no context |
There was a problem hiding this comment.
So, what did we expect the compiler to do that makes a delegate call to the resulting delegate a valid function call?
|
The way this current patch implements the delegate-to-function conversion by leaving the context pointer on the delegate default to I’ve tried to visualize the issue: import std.stdio;
void main() {
auto fun = function (size_t a) {
writeln("Fun: ", a);
};
auto del = delegate (size_t a) {
writeln("Del: ", a);
};
auto ehm = function(size_t a, size_t b) {
writeln("ehm: ", a);
writeln("ehm: ", b);
};
void delegate(size_t) fake1;
fake1.funcptr = fun;
void delegate(size_t) fake2;
fake2.ptr = cast(void*) 69;
fake2.funcptr = cast(void function(size_t)) ehm;
fun(7);
del(7);
fake1(7);
fake2(7);
} |
|
Closed as superseded by: #10599 |
No description provided.