[libcxx-commits] [libcxx] [libc++] Fix incomplete user-defined ctype specialization in test (PR #74630)
Stephan T. Lavavej via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Dec 6 17:18:41 PST 2023
================
@@ -73,15 +71,53 @@ struct char_traits<Char> {
static int_type eof() { return char_traits<char>::eof(); }
};
+// This ctype specialization treats all characters as spaces
template <>
-class ctype<Char> : public locale::facet {
+class ctype<Char> : public locale::facet, public ctype_base {
----------------
StephanTLavavej wrote:
I'm getting errors here:
```
D:\GitHub\STL\llvm-project\libcxx\test\std\localization\locale.categories\category.numeric\locale.num.get\user_defined_char_type.pass.cpp(76,21): error: direct base 'locale::facet' is inaccessible due to ambiguity:
class std::ctype<Char> -> class locale::facet
class std::ctype<Char> -> ctype_base -> class locale::facet [-Werror,-Winaccessible-base]
class ctype<Char> : public locale::facet, public ctype_base {
^~~~~~~~~~~~~~~~~~~~
```
```
D:\GitHub\STL\out\x64\out\inc\xlocale(454,12): error: ambiguous cast from base 'std::locale::facet' to derived 'std::ctype<Char>':
class locale::facet -> const class std::ctype<Char>
class locale::facet -> ctype_base -> const class std::ctype<Char>
return static_cast<const _Facet&>(*_Pf); // should be dynamic_cast
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```
I see that your PR is imitating \[locale.ctype.general\] which depicts `template<class charT> class ctype : public locale::facet, public ctype_base`. Unfortunately, microsoft/STL is weird - we have `ctype_base` deriving from `locale::facet` (which we shouldn't, but fixing it would break ABI), then our `ctype` derives from *only* `ctype_base`.
I'm not sure how to work around this divergence without adding an ifdef for MSVC's STL to this test. I'd be okay with you merging this PR as-is, then I'll look into what else is needed to get it to pass for us.
https://github.com/llvm/llvm-project/pull/74630
More information about the libcxx-commits
mailing list