www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 3559] New: DMD 1.048+ fails to take function pointer from overloaded member functions

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

           Summary: DMD 1.048+ fails to take function pointer from
                    overloaded member functions
           Product: D
           Version: 1.051
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: regression
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: klickverbot gmail.com



The following code compiles and works fine on DMD 1.047 and older (DMD 1.023
was the earliest one I tested), but no longer compiles with DMD 1.048 up to DMD
1.052 because the compiler cannot »choose« the correct overload when it tries
to create the delegate/function pointer. In older versions, the casts were
enough of a hint.

Note, however, that the code compiles without any errors if the overload I try
to get the address of is the last one declared – in the example below, getting
the address of »void foo( float a )« would work fine.

---

template addressOf( alias fn, Type ) {
  const addressOf = cast( Type )&fn;
}

class A {
  void foo( float a ) {}
  void foo( int a ) {}

  void bar() {
    void* dg = addressOf!( foo, void function( float ) );
    auto blah = cast( void delegate( float ) )&foo;
    if ( cast( void* )blah.funcptr == dg ) {
      // Stdout( "not overridden" ).newline;
    } else {
      // Stdout( "overridden" ).newline;
    }
  }
}

class B : A {
  override void foo( float a ) {}
  override void foo( int a ) {}
}

void main() {
  A a = new A();
  a.bar;

  A b = new B();
  b.bar;
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 30 2009
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3559


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |clugdbug yahoo.com.au




 The following code compiles and works fine on DMD 1.047 and older (DMD 1.023
 was the earliest one I tested), but no longer compiles with DMD 1.048 up to DMD
 1.052 because the compiler cannot »choose« the correct overload when it tries
 to create the delegate/function pointer. In older versions, the casts were
 enough of a hint.
This is because bug 52 was fixed. The compiler used to accept all kinds of garbage. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 12 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3559





 This is because bug 52 was fixed. The compiler used to accept all kinds of
 garbage.
If I am not misunderstanding you and the snippet I posted is in fact invalid code (it looks very strange indeed, but this is the only working version I and the folks at #d could come up with), there are now two seperate issues: Firstly, this bug should in fact be an »accepts-invalid« one, since it compiles if you put the function declarations in a certain order (see the original report). Secondly, there really ought to be a way to get this check to work for *both* overloaded and non-overloaded functions – or neither of them. With my language designer as well as my developer hat on, the restriction to non-overloaded functions is a rather annoying shortcoming… -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 12 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3559




*** Issue 4860 has been marked as a duplicate of this issue. ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 11 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3559


yebblies <yebblies gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull, wrong-code
                 CC|                            |yebblies gmail.com
            Version|1.051                       |D1 & D2
         AssignedTo|nobody puremagic.com        |yebblies gmail.com



https://github.com/D-Programming-Language/dmd/pull/711

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 11 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3559




Commit pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/35c67b1229306f0006209db21e34bd6d406136d7


Issue 3559 - DMD 1.048+ fails to take function pointer from overloaded member
functions

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 19 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3559




Commit pushed to dmd-1.x at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/b53732624fbb70a3e648f923384cf107915d8159
fix Issue 3559 - DMD 1.048+ fails to take function pointer from overloaded
member functions

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 19 2012
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3559


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla digitalmars.com
         Resolution|                            |FIXED


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