D and Secure Programming

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Sun Oct 2 18:24:45 PDT 2016


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


More information about the Digitalmars-d mailing list