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 14:28:05 +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> <mvm8tsd0zoq.fsf@hawking.suse.de> <CAKgNAkiZWYo4TdVhXhpiPhsdYBtMOJ0PWePTA2p1BKFBaWv=Ag@mail.gmail.com> <mvm37il0yxt.fsf@hawking.suse.de> <fb703f4f-6874-8820-1502-1ae09ebb74f6@gmail.com>
On Nov 21 2016, "Michael Kerrisk (man-pages)" <mtk.manpages@gmail.com> wrote:
> On 11/21/2016 02:01 PM, Andreas Schwab wrote:
>> On Nov 21 2016, "Michael Kerrisk (man-pages)" <mtk.manpages@gmail.com> wrote:
>>
>>> So, I'm not quite clear on the point that you are making in your
>>> second point. Given code such as:
>>>
>>> wchar_t w;
>>> ...
>>> if (iswlower((wint_t) w) ....
>>>
>>> Do you mean that the standards are saying that casting to wint_t here
>>> is guaranteed to be correct? I can't see the line of reasoning that
>>> leads there.
>>
>> Any valid value of wchar_t is representable by wint_t. I cannot find
>> any more convincing argument.
>
> Yes, but is a sign-extended wchar_t a valid value?
A valid value of wchar_t is a valid 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."