DMARC-Filter: OpenDMARC Filter v1.4.2 delorie.com 64VEpM4C2708972 Authentication-Results: delorie.com; dmarc=pass (p=none dis=none) header.from=cygwin.com Authentication-Results: delorie.com; spf=pass smtp.mailfrom=cygwin.com DKIM-Filter: OpenDKIM Filter v2.11.0 delorie.com 64VEpM4C2708972 Authentication-Results: delorie.com; dkim=pass (1024-bit key, unprotected) header.d=cygwin.com header.i=@cygwin.com header.a=rsa-sha256 header.s=default header.b=WPXhTTjA X-Recipient: archive-cygwin AT delorie DOT com DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DE04B4BA23EE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com; s=default; t=1780239081; bh=NUQf/AjUs7IQpLitrULNNibS85kugEEzh5VK9bG3+R0=; h=To:Subject:In-Reply-To:References:Date:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=WPXhTTjAmywuNDEp0qho7KWFu2XKm1mTFjPWWyy8pueuWc9yqYAbB9UR2mD+HaNuQ 3okFw1HH1ELZixY6wmyxebn9isBRMxO+Dy0+BQtXSdmRvhl4XKKBRg/lTb2dmY6S7w DeUdimeDlTT6yzi7SBc1ecxAsSacSd3kBESCaI4s= X-Original-To: cygwin AT cygwin DOT com Delivered-To: cygwin AT cygwin DOT com DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B38CA4BA2E22 ARC-Filter: OpenARC Filter v1.0.0 sourceware.org B38CA4BA2E22 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1780239061; cv=none; b=k5eLUwaM7aanC0BqM4BzkWDl043PFKr2xfsYg4qs2a33zkpVPruP/zg7guLvpbDYi+sBbKSi9fwsX0gKd0ZZm4HFuEooECeitlgAzMAG/WYxyE8eWCZ8CvLFlPI76IeW31ThAXm/dxJKQAr7CQdXP4f7/JhQ7JOmJdvqMUyDNUk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1780239061; c=relaxed/simple; bh=9qih3MppO+G0PngDd8WokuLKHaHo7XAOgCt0B2idaU8=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=N6PJ2tPMPHXhBZpEqYV+thK8MiJqpgX62NuoqpQ2PCG23dtafhNrRJq1mkApY5ULxnxzgbYsIFDDAdunptfzZFuDu0TqCKBCytNQBS7zs4FZoaThip6bamC0yy1fSk9fo+WxHhcj/SJTW55KrrWW7cdUBksUDVqWKjPSDwIZ15Y= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (1024-bit key, secure) header.d=nexgo.de header.i=@nexgo.de header.a=rsa-sha256 header.s=vfde-mb-mr2-23sep header.b=IVe/pCzQ DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B38CA4BA2E22 To: cygwin AT cygwin DOT com Subject: Re: wcwidth broken with gcc 16 In-Reply-To: (Thomas Wolff via Cygwin's message of "Sun, 31 May 2026 10:10:12 +0200") References: <874ikpawdk DOT fsf AT Gerda DOT invalid> <8ff2ab8d-dfdc-459c-96f3-ed4a4f451440 AT towo DOT net> <0140C1F4-CA22-46DE-AE21-69C5427C59B5 AT unified-streaming DOT com> <4f885156-7772-43d7-ab72-c88f0a7d1e52 AT towo DOT net> <112594ad-3c25-4dad-b1bc-071b4951ed98 AT towo DOT net> <97f0f3c6-9f2c-429c-aa8e-875b7806b275 AT towo DOT net> <8733z9jpfj DOT fsf AT Gerda DOT invalid> Date: Sun, 31 May 2026 16:50:47 +0200 Message-ID: <87pl2bab08.fsf@Gerda.invalid> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 X-purgate-server: smtpa03 X-purgate-type: clean X-purgate: clean X-purgate-size: 2256 X-purgate-ID: 155817::1780239054-07FFAD25-B9702372/0/0 X-BeenThere: cygwin AT cygwin DOT com X-Mailman-Version: 2.1.30 Precedence: list List-Id: General Cygwin discussions and problem reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: ASSI via Cygwin Reply-To: ASSI Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: cygwin-bounces~archive-cygwin=delorie DOT com AT cygwin DOT com Sender: "Cygwin" Thomas Wolff via Cygwin writes: > The implementation was extended to wint_t some years ago just to > enable the functionality indicated above, and it used to work until > gcc 15. That was by accident and dependent on undefined behaviour in the compiler for x86_64 ABI, as explained to you already. > For some change in gcc 16, it is now necessary to adapt the prototype > too, or gcc will apply the wrong extension and yield broken results. You don't own the prototype of a standardised public API function and don't get to change it for that very reason. The fix for your bug is easy enough and I don't get why you insist making it even more wrong instead. --8<---------------cut here---------------start------------->8--- diff --git a/newlib/libc/string/wcwidth.c b/newlib/libc/string/wcwidth.c index 8348eefe8..65604c061 100644 --- a/newlib/libc/string/wcwidth.c +++ b/newlib/libc/string/wcwidth.c @@ -230,7 +230,7 @@ __wcwidth (const wint_t ucs) } int -wcwidth (const wint_t wc) +wcwidth (const wchar_t wc) { wint_t wi = wc; --8<---------------cut here---------------end--------------->8--- Again, the assignment of wc to wi should do the proper zero extension you seek and keeps the public signature intact (and that was what the code did before your change). The stub then calls the implementation __wcwidth (which does take a wint_t argument), there just is no way of feeding it codepoints above 16 bit (and there never was such a possibility for correct code in Cygwin). Now I get that you think that sizeof(wchar_t) == sizeof(wint_t) should hold like on all GNU systems, but that isn't the case since Cygwin is on Windows and so WCHAR_MAX == 0xffffu (I think you know the backstory to that). So you cannot have code points beyond 16 bits as input to wcwidth anyway and everything else is treated correctly (and as before and after the change). Whether there needs to be a separate API for dealing with such codepoints (essentially in UTF-32) is a separate discussion. Regards, Achim. -- +<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+ SD adaptations for KORG EX-800 and Poly-800MkII V0.9: http://Synth.Stromeko.net/Downloads.html#KorgSDada -- Problem reports: https://cygwin.com/problems.html FAQ: https://cygwin.com/faq/ Documentation: https://cygwin.com/docs.html Unsubscribe info: https://cygwin.com/ml/#unsubscribe-simple