[Bug libstdc++/30127] New: std::has_facet returns true for not installed derived facets

sebor at roguewave dot com gcc-bugzilla@gcc.gnu.org
Sat Dec 9 00:30:00 GMT 2006


The program below is expected to run successfully to completion since there
is no MyCtype facet installed in the classic locale (and, in fact, no facet
of that type can exist since it doesn't have an accessible ctor).

$ cat u.cpp && g++ -dumpversion && g++ u.cpp -static && ./a.out
#include <cassert>
#include <locale>

struct MyCtype: std::ctype<char> { private: MyCtype (); };

int main ()
{
    assert (std::has_facet<std::ctype<char> >(std::locale::classic ()));
    assert (!std::has_facet<MyCtype>(std::locale::classic ()));
}
4.1.0
Assertion failed: !std::has_facet<MyCtype>(std::locale::classic ()), file
u.cpp, line 9
Abort (core dumped)


-- 
           Summary: std::has_facet returns true for not installed derived
                    facets
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: sebor at roguewave dot com


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



More information about the Gcc-bugs mailing list