From: Jonathan Wakely Date: Wed, 26 Feb 2020 14:00:07 +0000 (+0000) Subject: PR libstdc++/78552 only construct std::locale for C locale once X-Git-Tag: releases/gcc-9.3.0~78 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=84a5534ce2f8233e6fe9c957ec51a2328bfe60e3;p=thirdparty%2Fgcc.git PR libstdc++/78552 only construct std::locale for C locale once Backport from mainline 2019-10-09 Jonathan Wakely PR libstdc++/78552 * src/c++98/locale_init.cc (locale::classic()): Do not construct a new locale object for every call. (locale::_S_initialize_once()): Construct C locale here. --- diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 60f210176641..19ae4cef9fa5 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,13 @@ +2020-02-26 Jonathan Wakely + + Backport from mainline + 2019-10-09 Jonathan Wakely + + PR libstdc++/78552 + * src/c++98/locale_init.cc (locale::classic()): Do not construct a new + locale object for every call. + (locale::_S_initialize_once()): Construct C locale here. + 2020-01-24 Jonathan Wakely Backport from mainline diff --git a/libstdc++-v3/src/c++98/locale_init.cc b/libstdc++-v3/src/c++98/locale_init.cc index e5e9d74379f5..07d95dc09fd8 100644 --- a/libstdc++-v3/src/c++98/locale_init.cc +++ b/libstdc++-v3/src/c++98/locale_init.cc @@ -303,7 +303,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION locale::classic() { _S_initialize(); - return *(new (&c_locale) locale(_S_classic)); + return *(const locale*)c_locale; } void @@ -313,6 +313,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // One reference for _S_classic, one for _S_global _S_classic = new (&c_locale_impl) _Impl(2); _S_global = _S_classic; + new (&c_locale) locale(_S_classic); } void