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
Martin Sebor made changes - 09/Jul/07 12:41 AM
Field Original Value New Value
Assignee Martin Sebor [ sebor ]
Martin Sebor made changes - 09/Jul/07 12:41 AM
Status Open [ 1 ] In Progress [ 3 ]
Repository Revision Date User Message
ASF #554504 Mon Jul 09 00:42:39 UTC 2007 sebor 2007-07-08 Martin Sebor <sebor@roguewave.com>

STDCXX-478
* locale_eq.cpp (operator==): Removed the assumption that the same
user-defined facets must be stored at the same index in the array
in order for two locales in which they are installed to compare
equal.
Files Changed
MODIFY /incubator/stdcxx/trunk/src/locale_eq.cpp

Martin Sebor added a comment - 09/Jul/07 04:48 AM
Resolved. Will close after a regression test has been added to the test suite.

Martin Sebor made changes - 09/Jul/07 04:48 AM
Fix Version/s 4.2 [ 12311945 ]
Resolution Fixed [ 1 ]
Status In Progress [ 3 ] Resolved [ 5 ]