D and Secure Programming

Jacob via Digitalmars-d digitalmars-d at puremagic.com
Sun Oct 2 16:57:11 PDT 2016


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

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.


More information about the Digitalmars-d mailing list