Re: wcwidth broken with gcc 16

Brian Inglis <[email protected]> Sat, 30 May 2026 21:42:29 -0600
Newsgroups gmane.comp.lib.newlib,gmane.os.cygwin
Organization Systematic Software
Message-ID <[email protected]>
On 2026-05-30 11:40, ASSI via Cygwin wrote:
> Thomas Wolff via Cygwin writes:
>> The patch is already on the newlib mailing list.

	[PATCH] wchar.h: tweak wcwidth prototype parameter wchar_t -> wint_t

> The input parameter is supposed to be wchar_t, not wint_t (per POSIX and
> also the previous implementation), so I'd leave that alone.

>> Yeah, I forgot to type-extend also the include file back in 2018 :-(
>> but that made no difference so far, only now in gcc 16, as explained
>> by Drea in that issue:
>> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125451#c16
> 
> Just pun the type in the stub implementation, which would automatically
> happen (I think) since there's already an assignment of the input
> parameter from the POSIX wcwidth (wchar_t) to a local variable that has
> type wint_t.  And since that's not a function call but an assignment,
> the promotion rules should be correct for your application without any
> cast.

Both the man doc and definition in newlib/libc/string/wcwidth.c need
wcwidth (wint_t) changed to the POSIX 8 SUS V5 specified wcwidth (wchar_t);
newlib/libc/include/wchar.h is quite correct and okay as is!

	https://pubs.opengroup.org/onlinepubs/9799919799/functions/wcwidth.html

The standard definition prohibits WEOF, but allows null, non-spacing, or 
printable wide-character codes, corresponding to a valid character in the 
current locale, to be passed.
POSIX return codes are defined differently from __wcwidth results.
No errors are defined, and on valid input, errno is not changed.

-- 
Take care. Thanks, Brian Inglis              Calgary, Alberta, Canada

La perfection est atteinte                   Perfection is achieved
non pas lorsqu'il n'y a plus rien à ajouter  not when there is no more to add
mais lorsqu'il n'y a plus rien à retrancher  but when there is no more to cut
                                 -- Antoine de Saint-Exupéry