[Bug libstdc++/34449] New: use_facet<xxx_byname>(locale::classic()) returns true

sebor at roguewave dot com gcc-bugzilla@gcc.gnu.org
Thu Dec 13 04:53:00 GMT 2007


The test case below is expected to pass. With gcc 4.1.2 it aborts in the second
assert.

$ cat t.cpp && g++ t.cpp && ./a.out
#include <cassert>
#include <locale>

struct DerivedCtype: std::ctype_byname<char> {
    DerivedCtype (): std::ctype_byname<char>("") { }
};

template <class Facet>
bool check_use_facet (const std::locale &locale)
{
    try {
        std::use_facet<Facet>(locale);
    }
    catch (...) {
        return false;
    }
    return true;
}


int main ()
{
    const std::locale classic = std::locale::classic ();
    const std::locale named ("en_US.ISO-8859-1");
    const std::locale user (classic, new DerivedCtype);

    assert (check_use_facet<std::ctype<char> >(classic));
    assert (!check_use_facet<std::ctype_byname<char> >(classic));
    assert (!check_use_facet<DerivedCtype>(classic));

    assert (check_use_facet<std::ctype<char> >(named));
    assert (check_use_facet<std::ctype_byname<char> >(named));
    assert (!check_use_facet<DerivedCtype>(named));

    assert (check_use_facet<std::ctype<char> >(user));
    assert (check_use_facet<std::ctype_byname<char> >(user));
    assert (check_use_facet<DerivedCtype>(user));
}
a.out: t.cpp:28: int main(): Assertion
`!check_use_facet<std::ctype_byname<char>
 >(classic)' failed.


-- 
           Summary: use_facet<xxx_byname>(locale::classic()) returns true
           Product: gcc
           Version: 4.1.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: sebor at roguewave dot com
 GCC build triplet: x86_64-redhat-linux
  GCC host triplet: x86_64-redhat-linux
GCC target triplet: x86_64-redhat-linux


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34449



More information about the Gcc-bugs mailing list