Ignoring FORMAT_MESSAGE_IGNORE_INSERTS when retrieving system
error messages from FormatMessage may result in unexpected error messages and
trigger new exceptions. This patch changes the
std::system_category.message(int) to be the same as the flags in
gcc/plugin.cc:win32_error_msg()

libstdc++-v3/ChangeLog:

        * src/c++11/system_error.cc:
---
 libstdc++-v3/src/c++11/system_error.cc | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libstdc++-v3/src/c++11/system_error.cc 
b/libstdc++-v3/src/c++11/system_error.cc
index b9a0b2c158f..ea7b5cd1226 100644
--- a/libstdc++-v3/src/c++11/system_error.cc
+++ b/libstdc++-v3/src/c++11/system_error.cc
@@ -162,7 +162,9 @@ namespace
       char* buf = nullptr;
       auto len
        = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM
-                       | FORMAT_MESSAGE_ALLOCATE_BUFFER,
+                       | FORMAT_MESSAGE_ALLOCATE_BUFFER
+                       | FORMAT_MESSAGE_IGNORE_INSERTS
+                       | FORMAT_MESSAGE_MAX_WIDTH_MASK,
                        nullptr,
                        i,
                        LANG_USER_DEFAULT,
-- 
2.52.0

Reply via email to