When I compile the code in Visual Studio I get the following warning:
warning C4717: 'testif' : recursive on all control paths, function will cause runtime stack overflow

That could account for the crash...