[Issue 3559] New: DMD 1.048+ fails to take function pointer from overloaded member functions
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Nov 30 08:08:07 PST 2009
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 at puremagic.com
ReportedBy: klickverbot at gmail.com
--- Comment #0 from klickverbot at gmail.com 2009-11-30 08:08:06 PST ---
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: -------
More information about the Digitalmars-d-bugs
mailing list