https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118110

            Bug ID: 118110
           Summary: Incorrect facet instantiations for collate category in
                    std::locale
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: redi at gcc dot gnu.org
  Target Milestone: ---

The standard says that the required instantiations for the collate category
are:

collate_byname<char>, collate_byname<wchar_t>

which means this should work:

#include <locale>

int main()
{
  std::locale loc;
  (void) std::use_facet<std::collate_byname<char>>(loc);
}


With libstdc++ it fails:

terminate called after throwing an instance of 'std::bad_cast'
  what():  std::bad_cast
Aborted (core dumped)


That's because src/c++11/locale_init.cc creates the wrong types:

    _M_init_facet(new (&collate_c) std::collate<char>(1));

    _M_init_facet(new (&collate_w) std::collate<wchar_t>(1));

Reply via email to