www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Using delegates

reply Jason House <jason.james.house gmail.com> writes:
My first use of a delegate is causing a segmentation fault.  I'm 
assuming I'm missing something basic.  Can anyone point me in the right 
direction?

unittest{
   int callCounter=0;
   void increment(){
     callCounter++;
   }
   void delegate() dg = &increment; // Segmentation fault
   ...
}

Replacing the offending line with
void delegate() dg = delegate void() {callCounter++};
doesn't eliminate the segmentation fault.
Apr 15 2007
parent reply Jason House <jason.james.house gmail.com> writes:
Disregard my post.  I found my problem (and it was in a different 
place).  I had put in a bunch of writefln's to isolate my segfault.  (I 
have to get gdb working (upgrade it to 3.6).  I was disappointed that 
doing dmd -gc didn't let me use gdb)

Jason House wrote:
 My first use of a delegate is causing a segmentation fault.  I'm 
 assuming I'm missing something basic.  Can anyone point me in the right 
 direction?
 
 unittest{
   int callCounter=0;
   void increment(){
     callCounter++;
   }
   void delegate() dg = &increment; // Segmentation fault
   ...
 }
 
 Replacing the offending line with
 void delegate() dg = delegate void() {callCounter++};
 doesn't eliminate the segmentation fault.
Apr 15 2007
parent "Jarrett Billingsley" <kb3ctd2 yahoo.com> writes:
"Jason House" <jason.james.house gmail.com> wrote in message 
news:evtvrb$1up$1 digitalmars.com...
 Disregard my post.  I found my problem (and it was in a different place). 
 I had put in a bunch of writefln's to isolate my segfault.  (I have to get 
 gdb working (upgrade it to 3.6).  I was disappointed that doing dmd -gc 
 didn't let me use gdb)
Did you try the plain -g flag?
Apr 15 2007