Issue Details (XML | Word | Printable)

Key: STDCXX-478
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Martin Sebor
Reporter: Martin Sebor
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
C++ Standard Library

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

Created: 08/Jul/07 11:14 PM   Updated: 09/Jul/07 04:48 AM
Return to search
Component/s: 22. Localization
Affects Version/s: 4.1.2, 4.1.3
Fix Version/s: 4.2.0

Time Tracking:
Not Specified

Resolved: 09/Jul/07 04:48 AM
Resolution Date: 09/Jul/07 04:48 AM


 Description  « Hide
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



 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
No work has yet been logged on this issue.