From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mailout02.t-online.de (mailout02.t-online.de [194.25.134.17]) by sourceware.org (Postfix) with ESMTPS id E0E033858C78 for ; Tue, 15 Feb 2022 01:36:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E0E033858C78 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=t-online.de Authentication-Results: sourceware.org; spf=none smtp.mailfrom=t-online.de Received: from fwd82.dcpf.telekom.de (fwd82.aul.t-online.de [10.223.144.108]) by mailout02.t-online.de (Postfix) with SMTP id 983CA2037 for ; Tue, 15 Feb 2022 02:36:25 +0100 (CET) Received: from [192.168.178.26] ([79.228.92.68]) by fwd82.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384 encrypted) esmtp id 1nJmlJ-18aLMO0; Tue, 15 Feb 2022 02:36:13 +0100 Message-ID: <03ac7dd2-7082-2bb1-6c1b-c230764216e2@t-online.de> Date: Tue, 15 Feb 2022 02:36:08 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.6.0 Subject: Re: [:xdigit:] does not work with std::wstring in a Cygwin environment Content-Language: en-US To: cygwin@cygwin.com References: <53a83ef8dcc847e2914be35aa8c4525a@brillux.de> <87tud2mxn1.fsf@Rainer.invalid> From: =?UTF-8?Q?Hans-Bernhard_Br=c3=b6ker?= In-Reply-To: <87tud2mxn1.fsf@Rainer.invalid> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-TOI-EXPURGATEID: 150726::1644888973-0000B8A1-3C0FD123/0/0 CLEAN NORMAL X-TOI-MSGID: c48e4b6e-6c58-425e-bafe-b52b3faae823 X-Spam-Status: No, score=2.9 required=5.0 tests=BAYES_00, FREEMAIL_FROM, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, NICE_REPLY_A, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.4 X-Spam-Level: ** X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: cygwin@cygwin.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: General Cygwin discussions and problem reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Feb 2022 01:36:28 -0000 Am 13.02.2022 um 19:25 schrieb Achim Gratz: > Gans, Markus writes: >> This seems to be an internal Cygwin error: >> >> https://www.reddit.com/r/cpp_questions/comments/sp52gq/xdigit_does_not_work_with_stdwstring_in_a_cygwin/ > >> […] >> Question: Why does Cygwin not detect the letters a, b, c, d, e, and >> f as hexadecimal digits in a wide string? [...] > There is no OS specific configuration for Cygwin explicitly, instead > there is one for newlib that actually gets used. This piqued my curiosity, so I had a look at how libstdc++ is built. I found that at least for one crucial source file, called ctype_members.cc, cygwin builds do _not_ use the newlib edition, but rather the "generic" one. And that may very well be the problem here. The superficial cause of the problem is that member function _M_initialize_ctype() in libstdc++-v3/config/locale/generic/ctype_member.cc fills most of its array _M_wmask[] with zeroes instead of meaningful character class identifiers. The slightly deeper reason is that the companion array _M_bit[] is also suspiciously full of zeroes. But the real problem, IMHO, is that the type ctype::mask is just a plain char. That overflows the looped shift used to fill _M_bit[], which in turn leads to nonsense in _M_wmask[]. I didn't manage to find where this ctype::mask is defined, but the way it's used here cannot work if it's defined as plain char. The newlib edition of ctype_members.cc loops over just 8 bits instead of 16, which would allow this to work. So we either have to pick up a different type definition of ctype::mask, or a different edition of ctype_members.cc --- I guess it should be the newlib one.