aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3/src
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2024-01-30 14:48:28 +0000
committerJonathan Wakely <jwakely@redhat.com>2024-05-22 23:10:05 +0100
commit947a9c801e818f412ad4c669a49297c3512b3a6e (patch)
tree5e5b648687959794040c3d605e33aaf410ba5f0a /libstdc++-v3/src
parentb2fdd508d7e63158e9d2a6dd04f901d02900def3 (diff)
downloadgcc-947a9c801e818f412ad4c669a49297c3512b3a6e.zip
gcc-947a9c801e818f412ad4c669a49297c3512b3a6e.tar.gz
gcc-947a9c801e818f412ad4c669a49297c3512b3a6e.tar.bz2
libstdc++: Fix effects of combining locales [PR108323]
This fixes a bug in locale::combine where we fail to meet the standard's requirement that the result is unnamed. It also implements two library issues related to the names of combined locales (2295 and 3676). libstdc++-v3/ChangeLog: PR libstdc++/108323 * include/bits/locale_classes.tcc (locale(const locale&, Facet*)): Return a copy of the first argument when the facet pointer is null, as per LWG 2295. (locale::combine): Ensure the result is unnamed. * src/c++11/localename.cc (_M_replace_categories): Ignore whether the second locale has a name when cat == none, as per LWG 3676. * src/c++98/locale.cc (_M_install_facet): Use __builtin_expect to predict that the facet pointer is non-null. * testsuite/22_locale/locale/cons/names.cc: New test.
Diffstat (limited to 'libstdc++-v3/src')
-rw-r--r--libstdc++-v3/src/c++11/localename.cc4
-rw-r--r--libstdc++-v3/src/c++98/locale.cc2
2 files changed, 4 insertions, 2 deletions
diff --git a/libstdc++-v3/src/c++11/localename.cc b/libstdc++-v3/src/c++11/localename.cc
index cde94ec..909cf4c 100644
--- a/libstdc++-v3/src/c++11/localename.cc
+++ b/libstdc++-v3/src/c++11/localename.cc
@@ -326,7 +326,9 @@ const int num_facets = (
_M_replace_categories(const _Impl* __imp, category __cat)
{
category __mask = 1;
- if (!_M_names[0] || !__imp->_M_names[0])
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // 3676. Name of locale composed using std::locale::none
+ if (!_M_names[0] || (__cat != none && !__imp->_M_names[0]))
{
if (_M_names[0])
{
diff --git a/libstdc++-v3/src/c++98/locale.cc b/libstdc++-v3/src/c++98/locale.cc
index 3749408..0e7533e 100644
--- a/libstdc++-v3/src/c++98/locale.cc
+++ b/libstdc++-v3/src/c++98/locale.cc
@@ -323,7 +323,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
locale::_Impl::
_M_install_facet(const locale::id* __idp, const facet* __fp)
{
- if (__fp)
+ if (__builtin_expect(__fp != 0, 1))
{
size_t __index = __idp->_M_id();