Can't see variables values when debugging a program compiled with MSYS2 GCC/Clang and linked with UCRT on Windows


I'm trying to compile my C++ code with the MSYS2 GCC or Clang compiler on Windows. I have the following very simple program:

#include <iostream>
#include <string>

int main() {
std::string msg = "Hello, World!";
std::cout << msg << std::endl;
return 0;

I set a breakpoint at the second line in main(). It successfully break, but I can't see the content of the string msg. I can only see that the type is std::string. This behaviour is specific to STL objects. It works fine with primitive types. If I, however, compile with the bundled MinGW compiler, it works and I can see the string contents.

This is my MSYS2 Clang toolchain configuration for Clang:

Toolset: C:\msys64\clang64

CMake: C:\msys64\clang64\bin\cmake.exe

Build Tool: C:\msys64\clang64\bin\mingw32-make.exe
C Compiler: C:\msys64\clang64\bin\clang.exe
C++ Compiler: C:\msys64\clang64\bin\clang++.exe

Debugger: C:\msys64\clang64\bin\gdb

I'm using the GDB debugger since CLion doesn't seem to support LLDB on Windows.

How can I get the debugger to show variable values when compiling with MSYS2 Clang?

EDIT: After some research, I found that this happens because I'm using the MSYS2's Clang environment which links with UCRT instead of MSVCRT. If I use the MSYS2's MingGW (by replacing all the clang64 by mingw64 in my toolchain configuration) environment, it works fine and I can see the variable contents. I would however prefer using UCRT instead of MSVCRT.

Please sign in to leave a comment.