www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 1876] New: inside a non-static class method, should "&( f)" be same as "&(this.f)" ?

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1876

           Summary: inside a non-static class method, should "&(     f)" be
                    same as "&(this.f)" ?
           Product: D
           Version: 2.011
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: someanon yahoo.com


inside a non-static class method, should "&(     f)" be same as "&(this.f)" ?

$ cat fun.d
=========================
import std.stdio;

class A {
public:
  int delegate(int, int) dgs[4];
  int function(int, int) fps[4];
  int f(int x, int y) {
    writefln("here");
    int res = x + y;
    writefln(res);
    return res;
  }

void bug_1() {
  fps[] = [&(     f), &(     f), &(     f), &(     f)];  // bug 1: this line
shouldn't compile, but it passes the compiler and when run seg-faults!
  this.fps[0](1, 2);  // seg-faults here!
}

void bug_2() {
  dgs[] = [&(     f), &(     f), &(     f), &(     f)];  // bug 1: why this
line can't compile?
  // Error: e2ir: cannot cast from int function(int, int) to const(int
delegate(int, int))

  // in this context isn't "&(     f)" same as "&(this.f)" ?
  dgs[] = [&(this.f), &(this.f), &(this.f), &(this.f)];
  this.dgs[0](1, 2);
}

}

int main() {
  A a = new A();

  a.bug_1();

  a.bug_2();

  return 0;
}
=========================


-- 
Feb 27 2008
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1876





------- Comment #1 from someanon yahoo.com  2008-02-27 19:03 -------
Created an attachment (id=230)
 --> (http://d.puremagic.com/issues/attachment.cgi?id=230&action=view)
fun/dlg ptr bug


-- 
Feb 27 2008
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1876


bugzilla digitalmars.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED




------- Comment #2 from bugzilla digitalmars.com  2008-03-07 00:36 -------
Fixed dmd 2.012


-- 
Mar 06 2008