fstream file I/O crash when accessing libstdc++-6 in clang compiled program

Hey all,

Here's my simple program to demonstrate the issue. This is being compiled using clang with the mingw headers in windows.

#include <stdio.h>
#include <fstream>

     int main( void )

         std::ofstream ofs("whatever.txt");
         printf("Stream open\n");
         ofs << "testing\n";
         printf("Stream closed\n");

         return 0;

C:\MinGW\bin>gdb script.exe
GNU gdb (GDB) 7.5
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "i686-pc-mingw32".
For bug reporting instructions, please see:
Reading symbols from C:\MinGW\bin\script.exe...done.

(gdb) run

Starting program: C:\MinGW\bin\script.exe
[New Thread 9504.0x22a0]
[New Thread 9504.0x2674]
Stream open

Program received signal SIGSEGV, Segmentation fault.
0x6fc87a63 in libstdc++-6!_ZNSo6sentryC1ERSo ()
    from C:\MinGW\bin\libstdc++-6.dll

The result is the same compiling the program with clang built using visual studio or mingw. Of course, the program runs fine built with mingw g++.

What is the version of gcc which libstdc++.dll you're using from?