ср, 12 мая 2021 г. в 12:58, Antony Polukhin <antosh...@gmail.com>:
<...>
> Should we care about those users?

Looks like the answer is "yes". There are tests for that in
22_locale/ctype/requirements/explicit_instantiation.cc and
22_locale/money_get/cons/3.cc

Attaching a patch with review fixes (with ctype specialization for basic_string)

-- 
Best regards,
Antony Polukhin
diff --git a/libstdc++-v3/include/bits/locale_facets.h 
b/libstdc++-v3/include/bits/locale_facets.h
index 03724cf..bbd7da5 100644
--- a/libstdc++-v3/include/bits/locale_facets.h
+++ b/libstdc++-v3/include/bits/locale_facets.h
@@ -671,6 +671,19 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   template<typename _CharT>
     locale::id ctype<_CharT>::id;
 
+  // Compile time diagnostics for common misuse of [locale.convenience]
+  // functions with basic_string as a character type.
+  template<typename _CharT, typename _Traits, typename _Alloc>
+    class ctype<basic_string<_CharT, _Traits, _Alloc> >
+    {
+#if __cplusplus >= 201103L
+      static_assert(sizeof(_CharT) && false,
+                   "std::basic_string used as a character type");
+#endif
+      ctype();
+      ~ctype();
+    };
+
   /**
    *  @brief  The ctype<char> specialization.
    *  @ingroup locales
diff --git a/libstdc++-v3/testsuite/22_locale/ctype/is/string/89728_neg.cc 
b/libstdc++-v3/testsuite/22_locale/ctype/is/string/89728_neg.cc
new file mode 100644
index 0000000..268e03a
--- /dev/null
+++ b/libstdc++-v3/testsuite/22_locale/ctype/is/string/89728_neg.cc
@@ -0,0 +1,75 @@
+// { dg-do compile }
+
+// Copyright (C) 2021 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-error "basic_string used as a character type" "" { target c++11 } 0 }
+// { dg-error "is not a member of" "" { target *-*-* } 0 }
+// { dg-error "has no member named" "" { target *-*-* } 0 }
+
+#include <locale>
+
+template <class Char, int I>
+struct trait: std::char_traits<Char> {};
+
+template <class Char, int I>
+std::basic_string<Char, trait<Char, I> > make_str()
+{
+  return std::basic_string<Char, trait<Char, I> >();
+}
+
+void test01()
+{
+  const std::locale& loc = std::locale::classic();
+
+  std::isspace(std::string{}, loc);            // { dg-error "required from 
here" }
+  std::isprint(make_str<char, 0>(), loc);      // { dg-error "required from 
here" }
+  std::iscntrl(make_str<char, 1>(), loc);      // { dg-error "required from 
here" }
+  std::isupper(make_str<char, 2>(), loc);      // { dg-error "required from 
here" }
+  std::islower(make_str<char, 3>(), loc);      // { dg-error "required from 
here" }
+  std::isalpha(make_str<char, 4>(), loc);      // { dg-error "required from 
here" }
+  std::isdigit(make_str<char, 5>(), loc);      // { dg-error "required from 
here" }
+  std::ispunct(make_str<char, 6>(), loc);      // { dg-error "required from 
here" }
+  std::isxdigit(make_str<char, 7>(), loc);     // { dg-error "required from 
here" }
+  std::isalnum(make_str<char, 8>(), loc);      // { dg-error "required from 
here" }
+  std::isgraph(make_str<char, 9>(), loc);      // { dg-error "required from 
here" }
+  std::isblank(make_str<char, 10>(), loc);     // { dg-error "required from 
here" }
+  std::toupper(make_str<char, 11>(), loc);     // { dg-error "required from 
here" }
+  std::tolower(make_str<char, 12>(), loc);     // { dg-error "required from 
here" }
+}
+
+#ifdef _GLIBCXX_USE_WCHAR_T
+void test02()
+{
+  const std::locale& loc = std::locale::classic();
+
+  std::isspace(std::wstring{}, loc);           // { dg-error "required from 
here" }
+  std::isprint(make_str<wchar_t, 0>(), loc);   // { dg-error "required from 
here" }
+  std::iscntrl(make_str<wchar_t, 1>(), loc);   // { dg-error "required from 
here" }
+  std::isupper(make_str<wchar_t, 2>(), loc);   // { dg-error "required from 
here" }
+  std::islower(make_str<wchar_t, 3>(), loc);   // { dg-error "required from 
here" }
+  std::isalpha(make_str<wchar_t, 4>(), loc);   // { dg-error "required from 
here" }
+  std::isdigit(make_str<wchar_t, 5>(), loc);   // { dg-error "required from 
here" }
+  std::ispunct(make_str<wchar_t, 6>(), loc);   // { dg-error "required from 
here" }
+  std::isxdigit(make_str<wchar_t, 7>(), loc);  // { dg-error "required from 
here" }
+  std::isalnum(make_str<wchar_t, 8>(), loc);   // { dg-error "required from 
here" }
+  std::isgraph(make_str<wchar_t, 9>(), loc);   // { dg-error "required from 
here" }
+  std::isblank(make_str<wchar_t, 10>(), loc);  // { dg-error "required from 
here" }
+  std::toupper(make_str<wchar_t, 11>(), loc);  // { dg-error "required from 
here" }
+  std::tolower(make_str<wchar_t, 12>(), loc);  // { dg-error "required from 
here" }
+}
+#endif

Reply via email to