I am porting code from *nix to windows starting off with mingw. I have mingw32-gcc v4.4.0 which compiles the code without any problems. However if an exception is thrown at any point the program simply quits with The application has requested the Runtime to terminate in an unusual way ... blah blah blah. After a few minutes on googling I have found that this might be to do with "Dwarf-2 vs. SJLJ unwinding" (http://www.tdragon.net/recentgcc/). And surely enough I find that mingw32-gcc was configured with --disable-sjlj-exceptions --with-dwarf2.
My question is "Is the assumption that the current mingw does not handle exceptions 'through a foreign stack area' correct and hence a new build of mingw32-gcc will solve the problem Or should I still look for the problem in my code?"
Without seeing your code it's impossible to tell. If you do not return a value, or return an invalid value from your main() function then I've seen that cause this issue before. If your application runs at all I would look at the code before the compiler.
Found out that I was doing a static link which was forcing g++ to link to both mingw and cygwin libraries (I have both on my machine). Changing to a dynamic link solved the problem.