D and Secure Programming
Jacob via Digitalmars-d
digitalmars-d at puremagic.com
Sun Oct 2 19:14:52 PDT 2016
On Monday, 3 October 2016 at 01:24:45 UTC, Walter Bright wrote:
> On 10/2/2016 4:57 PM, Jacob wrote:
>> While on the subject, taking the address of a struct's method
>> returns an
>> incorrect type that allows it to be called incorrectly even
>> with @safe. Which is
>> a bit ironic cause then it can't be cast'd to a type that is
>> actually safe to use.
>>
>> auto func = &SomeStruct.someFunc;
>> func(); // ops runtime error, allows calling function that
>> needs an object
>>
>
> Please file bugzilla issues for these sorts of things. Thanks!
>
> > C++ makes this a pointer to a member function which looks
> like: "void
> > (SomeStruct::*)()" for the example above. Either way for
> safety and just having
> > a defined way to call a pointer to a member function would be
> nice.
>
> http://digitalmars.com/articles/b68.html
Has existed since 2010...
https://issues.dlang.org/show_bug.cgi?id=3720
Also using a proxy is suboptimal, if you use a cast() and add in
"ref SomeStruct" as a parameter, it functions properly and
doesn't require the proxy.
More information about the Digitalmars-d
mailing list