[Issue 13850] mixin template accepts delegates as function parameters

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Mar 30 08:39:14 UTC 2023


https://issues.dlang.org/show_bug.cgi?id=13850

--- Comment #7 from RazvanN <razvan.nitu1305 at gmail.com> ---
Well, what we are seeing here is just another manifestation of 3720:
https://issues.dlang.org/show_bug.cgi?id=3720 . The underlying issue is that
when you take the address of a member function that is not attached to an
instance, the pointer of the function (in the .txt) section is returned. The
type is not a delegate because it was intended to be used in conjunction with
the .funcptr and .ptr properties of delegates (you can take the address of some
delegate as a function pointer and set it as the funcptr of another delegate).
I'm saying this is a good design, I am just stating what the situation is. In
this context, the code compiles because the function are not using any instance
members therefore the context pointer, even though it is garbage it is not used
at all. If you add a member to the class and try to access it in those
functions you will probably get a segfault.

I am inclined to close this as a dupe of 3720, as fixing that will most likely
fix this case also.

--


More information about the Digitalmars-d-bugs mailing list