Bug 441639 - libstdc++-v3 locale - collate and time swapped
libstdc++-v3 locale - collate and time swapped
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: gcc (Show other bugs)
5.2
All Linux
low Severity low
: rc
: ---
Assigned To: Jakub Jelinek
http://gcc.gnu.org/bugzilla/show_bug....
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2008-04-09 05:14 EDT by Andrew Mann
Modified: 2009-01-20 16:25 EST (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2009-01-20 16:25:04 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
Apply upstream fix for GCC PR29217 (1.10 KB, patch)
2008-04-09 05:14 EDT, Andrew Mann
no flags Details | Diff


External Trackers
Tracker ID Priority Status Summary Last Updated
GNU Compiler Collection 29217 None None None Never

  None (edit)
Description Andrew Mann 2008-04-09 05:14:37 EDT
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.
Comment 1 Andrew Mann 2008-04-09 05:14:37 EDT
Created attachment 301764 [details]
Apply upstream fix for GCC PR29217
Comment 2 RHEL Product and Program Management 2008-06-02 16:09:04 EDT
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.
Comment 9 errata-xmlrpc 2009-01-20 16:25:04 EST
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

Note You need to log in before you can comment on or make changes to this bug.