From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31891 invoked by alias); 5 Feb 2003 10:46:01 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 31871 invoked by uid 71); 5 Feb 2003 10:46:00 -0000 Resent-Date: 5 Feb 2003 10:46:00 -0000 Resent-Message-ID: <20030205104600.31870.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org Resent-Reply-To: gcc-gnats@gcc.gnu.org, peturr02@ru.is Received: (qmail 30487 invoked by uid 48); 5 Feb 2003 10:39:55 -0000 Message-Id: <20030205103955.30486.qmail@sources.redhat.com> Date: Wed, 05 Feb 2003 10:46:00 -0000 From: peturr02@ru.is Reply-To: peturr02@ru.is To: gcc-gnats@gcc.gnu.org X-Send-Pr-Version: gnatsweb-2.9.3 (1.1.1.1.2.31) Subject: libstdc++/9581: Array versions of ctype::do_narrow and do_widen broken. X-SW-Source: 2003-02/txt/msg00249.txt.bz2 List-Id: >Number: 9581 >Category: libstdc++ >Synopsis: Array versions of ctype::do_narrow and do_widen broken. >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: sw-bug >Submitter-Id: net >Arrival-Date: Wed Feb 05 10:46:00 UTC 2003 >Closed-Date: >Last-Modified: >Originator: peturr02@ru.is >Release: gcc-3.2.1 >Organization: >Environment: Red Hat Linux 8.0 >Description: The conversion performed by the array versions of ctype::do_widen and do_narrow don't match the conversions done by the single character versions (at least in locales with multi-byte charsets). Currently, wcsrtombs and mbsrtowcs are used to implement these functions. These functions convert between wide characters and multi-byte characters, but do_widen and do_narrow assume a one-to-one mapping between wide and narrow characters. The documentation might also point out that these functions are mostly useless, since a one-to-one mapping usually doesn't exist. >How-To-Repeat: See attachment. >Fix: >Release-Note: >Audit-Trail: >Unformatted: ----gnatsweb-attachment---- Content-Type: text/plain; name="ctypebug.cc" Content-Disposition: inline; filename="ctypebug.cc" #include #undef NDEBUG #include int main() { using namespace std; locale loc ("en_US.UTF-8"); locale::global(loc); const char* strlit = "\xc2\x80"; const wchar_t* wstrlit = L"\x80"; const ctype& wct = use_facet >(loc); wchar_t wbuf[3]; wct.widen(strlit, strlit + 3, wbuf); assert(wbuf[0] == wct.widen(strlit[0])); assert(wbuf[1] == wct.widen(strlit[1])); assert(wbuf[2] == wct.widen(strlit[2])); char buf[2]; wct.narrow(wstrlit, wstrlit + 2, '\0', buf); assert(buf[0] == wct.narrow(wstrlit[0], '\0')); assert(buf[1] == wct.narrow(wstrlit[1], '\0')); return 0; }