From e367d65b6e5110b196f90a58750d423d60daa446 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Wed, 1 Nov 2017 20:59:34 +0200 Subject: [PATCH] Fix use of _alloca under g++/clang (mingw/cygwin) --- include/boost/system/detail/error_code.ipp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/boost/system/detail/error_code.ipp b/include/boost/system/detail/error_code.ipp index a7fe3ef..a2b3f11 100644 --- a/include/boost/system/detail/error_code.ipp +++ b/include/boost/system/detail/error_code.ipp @@ -411,8 +411,14 @@ namespace } int num_chars = (buf.size() + 1) * 2; + boost::winapi::LPSTR_ narrow_buffer = +#if defined(__GNUC__) + (boost::winapi::LPSTR_)__builtin_alloca(num_chars); +#else (boost::winapi::LPSTR_)_alloca(num_chars); +#endif + if (boost::winapi::WideCharToMultiByte(boost::winapi::CP_ACP_, 0, buf.c_str(), -1, narrow_buffer, num_chars, NULL, NULL) == 0) {