Recursive function calls being skipped

BCS ao at pathlink.com
Mon Apr 23 17:09:15 PDT 2007


Reply to Derek,

> I have a situation like this ...
> 
> void Foo(T)(T pData)
> {
> T xx;
> writefln("ENTRY");
> // skip a whole lot of code ...
> if (some_condition)
> {
> writefln("A");
> Foo( xx );
> Writefln("B");
> }
> // blah blah blah ...
> writefln("EXIT");
> }
> And the output I'm getting is ...
> 
> ENTRY
> A
> B
> EXIT
> but I was expecting ...
> ENTRY
> A
> ENTRY
> EXIT
> B
> EXIT
> The code is inside a very large program so I'm a bit loathed to start
> chopping it up to find the minimum program that still demonstrates the
> effect. I suppose I could examine the object code to see what's being
> generated but I was hoping that someone might give me a clue first.
> 

First I'd do this

void Foo(T)(T pData)
{
T xx;
writefln("ENTRY");
scope(exit)writefln("EXIT");
[...]
}

That will make sure that no exceptions are messing you up.




More information about the Digitalmars-d-bugs mailing list