this block dwt, and dmd 1.062 beta still failure. but dmd2 is work.
Comment #2 by changlon — 2010-06-27T21:18:05Z
I test this bug in linux and windows, dmd1.062 print wrong address in linux too.
dmd 2.047 is work for windows and linux.
I use obj2asm to compare the d1 and d2 object file, but i have no ideal where is wrong .
http://gool.googlecode.com/files/bug4277.tar
this package include the bug2177.d (for both dmd1 and dmd2), 1.asm (from dmd1 generate bug2177.o file) and 2.asm (from dmd2 generate bug2177.o file).
Comment #3 by changlon — 2010-06-27T21:19:19Z
(In reply to comment #2)
> I test this bug in linux and windows, dmd1.062 print wrong address in linux
> too.
>
> dmd 2.047 is work for windows and linux.
>
>
> I use obj2asm to compare the d1 and d2 object file, but i have no ideal where
> is wrong .
>
>
> http://gool.googlecode.com/files/bug4277.tar
> this package include the bug2177.d (for both dmd1 and dmd2), 1.asm (from dmd1
> generate bug2177.o file) and 2.asm (from dmd2 generate bug2177.o file).
sorry , i mean bug4277.d
You're creating a delegate of a nested function, and then return it. This is not allowed in D1. It's like writing "int* foo() { int x; return x; }" and then expecting the returned value is valid.
Returning delegates to nested functions is allowed in D2, though.
Comment #8 by changlon — 2010-06-28T20:45:28Z
IF I understood correct, the dwt.widgets.Listener design by Frank Benoit is danger in d1. the source is:
------------------------------------------
module dwt.widgets.Listener;
import dwt.widgets.Event;
import tango.core.Traits;
import tango.core.Tuple;
public interface Listener {
void handleEvent (Event event);
}
/// Helper class for the dgListener template function
private class _DgListenerT(Dg,T...) : Listener {
alias ParameterTupleOf!(Dg) DgArgs;
static assert( is(DgArgs == Tuple!(Event,T)),
"Delegate args not correct: delegate args: ("~DgArgs.stringof~") vs. passed args: ("~Tuple!(Event,T).stringof~")" );
Dg dg;
T t;
private this( Dg dg, T t ){
this.dg = dg;
static if( T.length > 0 ){
this.t = t;
}
}
void handleEvent( Event e ){
dg(e,t);
}
}
Listener dgListener( Dg, T... )( Dg dg, T args ){
return new _DgListenerT!( Dg, T )( dg, args );
}