[Issue 3720] New: Taking address of member functions possible without an instance

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Jan 18 15:04:38 PST 2010


http://d.puremagic.com/issues/show_bug.cgi?id=3720

           Summary: Taking address of member functions possible without an
                    instance
           Product: D
           Version: 2.039
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: tomeksowi at gmail.com


--- Comment #0 from Tomasz Sowiński <tomeksowi at gmail.com> 2010-01-18 15:04:35 PST ---
struct S {
    int a;
    void fun() {
        this.a = 1;
    }
}

void main() {
    auto fp = &S.fun;
    fp();
}

Outputs:
object.Error: Access Violation


The solution is either to delegalize it or (better) include the hidden
parameter into the function pointer signature. So that &S.fun would be of type
void function(ref S).

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list