www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - posible delegate/inerfunktion bug

reply Johan Granberg <lijat.meREM OVEgmail.com> writes:
I was writing a callback system for my program when the following issue 
turned up. (gdc mac 0.17)

ext is a bool i a superclass

void classfunktion()
{
	//crashes with access violation
	//auto exitfunk=delegate bool(){return ext=true;};
	//does not change ext
	//bool exitfunk(){return ext=true;};
	
	//used here
	widgets[$-1]=new Widget("exit button",p,window,input,&exitfunk);
}

when i declared it at class level it works
bool exitfunk(){return ext=true;};

is this expected behavior with delegate and inner functions or is it a bug?
Apr 03 2006
parent Aho H. Ullman <Aho_member pathlink.com> writes:
In article <e0qq49$2j9$1 digitaldaemon.com>, Johan Granberg says...
	widgets[$-1]=new Widget("exit button",p,window,input,&exitfunk);
is this expected behavior with delegate and inner functions or is it a bug?

You are storing a reference to a local variable.
Apr 04 2006