2

I am using g++ to compile a very simple c++-program with

g++ main.cpp -o main.exe

My code:

#include <string>
int main() {
    std::string a;
    return 0;
}

[Windows 10 | mingw-gcc-g++ 6.3.0-1]

When I try to run the created main.exe, I get the exit code: 3221225785.
gdb returns:

(gdb) start
Temporary breakpoint 2 at 0x401464
Starting program: C:/[...]/main.exe
[New Thread 14272.0x1238]
[New Thread 14272.0x548c]
[New Thread 14272.0x42fc]
[New Thread 14272.0x3db4]
During startup program exited with code 0xc0000139.

I know that the error is caused by declaring the string in combination with g++. If I use clang++ to compile the code, everything works just fine. Does anyone know what exactly causes this error, how I could find out myself or even how to fix it?


I found this post, but if its possible somehow, I would prefer to not downgrade mingw-gcc-g++. The dependencywalker is not up to date and only returns false negatives as far as I know because it cannot handle MS API-sets.


[Edit] Small addendum:

I get the same error declaring a std::vector, std::set or std::map, but std::array for example works without problems. Do I use a deprecated library or something?

Gmork
  • 171
  • 1
  • 8
  • If you get away with array, but not vector or strings, it must have something to do with memory allocation. – papagaga Dec 29 '17 at 10:35
  • 1
    Thanks for your reply. I found out that static linking the standard library with -static-libstdc++ fixes the problem for me. So I think it is a linker error only arising when dynamically linking a library - perhaps caused when using some kind of memory allocation? – Gmork Dec 29 '17 at 11:26

0 Answers0