Appears to fail after the statement ends, so during the cleanup of the anonymous string object. If you switch it to be named like: string foo = contentGet(); cerr << "Result: '" << foo << "'" << endl; cerr << "Done." << endl; it will crash when the function exits, so it's something to do with destroying that string object. Running the nocygwin version with gdb gets us: warning: HEAP[xxx-nocygwin.exe]: warning: Invalid Address specified to RtlFreeHeap( 003D0000, 0043D150 )