This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: Signedness of wchar_t and wint_t leads to problems with gcc -Wsign-conversion
- From: Andreas Schwab <schwab at suse dot de>
- To: "Michael Kerrisk \(man-pages\)" <mtk dot manpages at gmail dot com>
- Cc: "libc-alpha\@sourceware.org" <libc-alpha at sourceware dot org>, Igor Liferenko <igor dot liferenko at gmail dot com>
- Date: Mon, 21 Nov 2016 13:45:09 +0100
- Subject: Re: Signedness of wchar_t and wint_t leads to problems with gcc -Wsign-conversion
- Authentication-results: sourceware.org; auth=none
- References: <CAKgNAkhjsE=OpLj=S9btNBQVj-OAr7Fd3y6RDp4M7SFkoPGHbg@mail.gmail.com>
On Nov 21 2016, "Michael Kerrisk (man-pages)" <mtk.manpages@gmail.com> wrote:
> However, we don't have a similar solution for iswlower(), because
> there is no "(unsigned wchar_t)" cast. And casting to (wint_t) seems
> incorrect to me, because if wchar_t is a signed type smaller than
> wint_t, then sign extension could occur.
wint_t is "an integer type capable of storing any valid value of wchar_t
or WEOF". If the sign-extended value of a wchar_t isn't a valid value
then you have undefined behaviour. WEOF must be defined such that no
conflict can occur with any valid wchar_t value.
Andreas.
--
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."