std::locale::operator==() inconsistent for locales with the same user-defined 
facets
------------------------------------------------------------------------------------

                 Key: STDCXX-478
                 URL: https://issues.apache.org/jira/browse/STDCXX-478
             Project: C++ Standard Library
          Issue Type: Bug
          Components: 22. Localization
    Affects Versions: 4.1.2, 4.1.3
            Reporter: Martin Sebor


The program below is intended to take advantage of the stdcxx extension whereby 
two unnamed locales compare equal when they represent the exact same object 
(i.e., when all their facets are exactly same). The program passes the first 
assertion but aborts in the second one:

$ cat t.cpp && make t && ./t
#include <cassert>
#include <cstdio>
#include <locale>

struct A: std::num_put<char, char*> { A (): std::num_put<char, char*>(1) { } };
struct B: std::num_put<char, char*> { B (): std::num_put<char, char*>(1) { } };

int main ()
{
    const std::locale en ("en_US");

    const A* const a = new A;
    const B* const b = new B;

    {
        const std::locale usr1 (std::locale (en, a), b);
        const std::locale usr2 (std::locale (en, a), b);

        std::printf ("\"%s\" == \"%s\"\n",
                     usr1.name ().c_str (), usr2.name ().c_str ());

       assert (usr1 == usr2);
    }

    {
        const std::locale usr1 (std::locale (en, a), b);
        const std::locale usr2 (std::locale (en, b), a);

        std::printf ("\"%s\" == \"%s\"\n",
                     usr1.name ().c_str (), usr2.name ().c_str ());

       assert (usr1 == usr2);
    }
}
icc -c -I/home/sebor/stdcxx/include/ansi -D_RWSTDDEBUG   -D_REENTRANT 
-I/home/sebor/stdcxx/include -I/build/sebor/stdcxx-icc-10.0.025-15S/include 
-I/home/sebor/stdcxx/examples/include  -cxxlib-nostd -g   -w1   t.cpp
icc t.o -o t -cxxlib-nostd  -lpthread  
-L/build/sebor/stdcxx-icc-10.0.025-15S/lib  -lstd15S -lcxaguard -lsupc++ -lm 
"*" == "*"
"*" == "*"
t: t.cpp:32: int main(): Assertion `usr1 == usr2' failed.
Aborted


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to