diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2019-04-26 15:04:45 +0100 |
---|---|---|
committer | Jonathan Wakely <redi@gcc.gnu.org> | 2019-04-26 15:04:45 +0100 |
commit | 8281e3b8ea4fe692c92c8781636a36e81f4e038f (patch) | |
tree | fbfb8aa99ea6a9acdf78561de7e7747ac2b47856 | |
parent | 3addb7b937c614101cd3bb7a7e91cd3fc84d30b5 (diff) | |
download | gcc-8281e3b8ea4fe692c92c8781636a36e81f4e038f.zip gcc-8281e3b8ea4fe692c92c8781636a36e81f4e038f.tar.gz gcc-8281e3b8ea4fe692c92c8781636a36e81f4e038f.tar.bz2 |
Reduce code instantiated by filesystem::path::_S_convert_loc
Jakub noted in https://gcc.gnu.org/ml/libstdc++/2019-04/msg00140.html
that an unwanted std::wstring::_M_replace_dispatch symbol has started to
be exported from the Fedora shared library. This symbol is triggered by
the instantiation of std::wstring::assign(const char*, const char*) from
std::__str_codecvt_in which is called from path::_S_convert_loc. The
branch that triggers that instantiation can't actually happen in that
case, because codecvt facets will only return noconv when the input and
output types are the same. Guarding the assign call with an if-constexpr
check that the types are the same avoids instantiating template
specializations that will never actually be needed.
* config/abi/pre/gnu.ver (GLIBCXX_3.4): Replace wildcard that matches
wstring::_M_replace_dispatch with more specific patterns.
* include/bits/fs_path.h (path::_S_convert_loc<_InputIterator>):
Create const std::string to avoid redundant call to _S_convert_loc
with non-const pointers.
* include/bits/locale_conv.h (__do_str_codecvt): Use if-constexpr to
avoid unnecessary basic_string::assign instantiations.
From-SVN: r270602
-rw-r--r-- | libstdc++-v3/ChangeLog | 8 | ||||
-rw-r--r-- | libstdc++-v3/config/abi/pre/gnu.ver | 3 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/fs_path.h | 2 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/locale_conv.h | 10 |
4 files changed, 19 insertions, 4 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index d2f8ed4..61841e8 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,5 +1,13 @@ 2019-04-26 Jonathan Wakely <jwakely@redhat.com> + * config/abi/pre/gnu.ver (GLIBCXX_3.4): Replace wildcard that matches + wstring::_M_replace_dispatch with more specific patterns. + * include/bits/fs_path.h (path::_S_convert_loc<_InputIterator>): + Create const std::string to avoid redundant call to _S_convert_loc + with non-const pointers. + * include/bits/locale_conv.h (__do_str_codecvt): Use if-constexpr to + avoid unnecessary basic_string::assign instantiations. + * include/std/memory (__uses_alloc_args): Add string-literal to static_assert, to match the one in __uses_alloc. [__cpp_concepts] (_Std_pair): Use C++2a syntax for concept. diff --git a/libstdc++-v3/config/abi/pre/gnu.ver b/libstdc++-v3/config/abi/pre/gnu.ver index e8cf6f0..7eff4e9 100644 --- a/libstdc++-v3/config/abi/pre/gnu.ver +++ b/libstdc++-v3/config/abi/pre/gnu.ver @@ -299,7 +299,8 @@ GLIBCXX_3.4 { _ZNSbIwSt11char_traitsIwESaIwEE12_S_constructE[jmy]wRKS1_; _ZNSbIwSt11char_traitsIwESaIwEE12_S_empty_repEv; _ZNSbIwSt11char_traitsIwESaIwEE13_S_copy_chars*; - _ZNSbIwSt11char_traitsIwESaIwEE[0-9][0-9]_M_replace*; + _ZNSbIwSt11char_traitsIwESaIwEE14_M_replace_aux*; + _ZNSbIwSt11char_traitsIwESaIwEE15_M_replace_safe*; _ZNSbIwSt11char_traitsIwESaIwEE4_Rep10_M_destroy*; _ZNSbIwSt11char_traitsIwESaIwEE4_Rep10_M_dispose*; _ZNSbIwSt11char_traitsIwESaIwEE4_Rep10_M_refcopyEv; diff --git a/libstdc++-v3/include/bits/fs_path.h b/libstdc++-v3/include/bits/fs_path.h index 3674b43..28878c6 100644 --- a/libstdc++-v3/include/bits/fs_path.h +++ b/libstdc++-v3/include/bits/fs_path.h @@ -539,7 +539,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 _S_convert_loc(_InputIterator __src, __null_terminated, const std::locale& __loc) { - std::string __s = _S_string_from_iter(__src); + const std::string __s = _S_string_from_iter(__src); return _S_convert_loc(__s.data(), __s.data() + __s.size(), __loc); } diff --git a/libstdc++-v3/include/bits/locale_conv.h b/libstdc++-v3/include/bits/locale_conv.h index d7510df..4cb9c39 100644 --- a/libstdc++-v3/include/bits/locale_conv.h +++ b/libstdc++-v3/include/bits/locale_conv.h @@ -88,8 +88,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION if (__result == codecvt_base::noconv) { - __outstr.assign(__first, __last); - __count = __last - __first; + // The codecvt facet will only return noconv when the types are + // the same, so avoid instantiating basic_string::assign otherwise + if _GLIBCXX17_CONSTEXPR (is_same<typename _Codecvt::intern_type, + typename _Codecvt::extern_type>()) + { + __outstr.assign(__first, __last); + __count = __last - __first; + } } else { |