Description of problem: In gnu libstdc++v3 within gcc 4.1.1/4.1.2, the numerical encoding of the time and collate categories are swapped. This results in programs that individually set locale categories using std::locale::collate or std::locale::time to operate incorrectly when run on RHEL5 (or when built on RHEL5 and static linked to libstdc++). This has been fixed in gcc 4.2.0 but not yet backported into RHEL5 gcc 4.1.2. Version-Release number of selected component (if applicable): 4.1.2-14.el5 How reproducible: Always. Steps to Reproduce: The following short program demonstrates the problem: #include <iostream> #include <string> #include <ctime> #include <sstream> using namespace std; locale SetCppLocale() { locale loc; locale temp(std::locale::classic(), "en_US.UTF-8", std::locale::collate ); locale oldLoc = std::locale::global(temp); return oldLoc; } string DoDateTimeString() { time_t utcTime; time(&utcTime); struct tm *time = localtime(&utcTime); char buffer[300]; strftime(buffer, 300, "%c", time); return string(buffer); } int main() { string time = DoDateTimeString(); cout << "Time in default locale: " << time << endl; locale oldLoc = SetCppLocale(); cout << "Old locale name: " << oldLoc.name() << endl; locale newLoc; cout << "New locale name: " << newLoc.name() << endl; time = DoDateTimeString(); cout << "Time in hybrid locale: " << time << endl; return 0; } Actual results: (generated from RHEL5 w/ latest gcc errata) Time in default locale: Wed Apr 9 04:59:41 2008 Old locale name: C New locale name: LC_CTYPE=C;LC_NUMERIC=C;LC_TIME=en_US.UTF-8;LC_COLLATE=C;LC_MONETARY=C;LC_MESSAGES=C;LC_PAPER=C;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=C;LC_IDENTIFICATION=C Time in hybrid locale: Wed 09 Apr 2008 04:59:41 AM EDT Note that only std::locale::collate was set, and NOT std::locale::time . In the resulting locale name, LC_TIME has been changed to en_US.UTF-8 instead of LC_COLLATE. The current time display lines show that this is not just a name string output bug, but affects locale handling of dates as well. Expected results: (generated from patched system) Time in default locale: Wed Apr 9 04:55:50 2008 Old locale name: C New locale name: LC_CTYPE=C;LC_NUMERIC=C;LC_TIME=C;LC_COLLATE=en_US.UTF-8;LC_MONETARY=C;LC_MESSAGES=C;LC_PAPER=C;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=C;LC_IDENTIFICATION=C Time in hybrid locale: Wed Apr 9 04:55:50 2008 Additional info: This bug is fixed in gcc 4.2.0 and is described at http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29217 The attached patch applies the same workaround code from gcc mainline to the RHEL5 gcc-4.1.2-14.el5 source.
Created attachment 301764 [details] Apply upstream fix for GCC PR29217
This request was evaluated by Red Hat Product Management for inclusion in a Red Hat Enterprise Linux maintenance release. Product Management has requested further review of this request by Red Hat Engineering, for potential inclusion in a Red Hat Enterprise Linux Update release for currently deployed products. This request is not yet committed for inclusion in an Update release.
An advisory has been issued which should help the problem described in this bug report. This report is therefore being closed with a resolution of ERRATA. For more information on therefore solution and/or where to find the updated files, please follow the link below. You may reopen this bug report if the solution does not work for you. http://rhn.redhat.com/errata/RHBA-2009-0157.html