Captain Kirk is dumping the core to try to escape from the collapsing black hole. ;D
Hmmm... I'm not exactly sure what causes a core dump, but your function called fun2() looks a little suspicious. I don't know if it was a typo or if you meant for it to be this way, but fun2() is executing recursively (meaning it is calling itself). This is not illegal in C++, but as there doesn't seem to be a way for your function to ever end it will just keep getting deeper and deeper into the recursion.
That might cause the Enterprise to lose it's warp core. :)