Signedness of wchar_t and wint_t leads to problems with gcc -Wsign-conversion
Michael Kerrisk (man-pages)
mtk.manpages@gmail.com
Mon Nov 21 13:07:00 GMT 2016
On 11/21/2016 02:01 PM, Szabolcs Nagy wrote:
> On 21/11/16 12:54, Michael Kerrisk (man-pages) 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.
>
> an implementation is allowed to support wide
> characters with >=0 value only (independently
> of signedness of wchar_t).
Yes, it's allowed to, but it may also do otherwise, as in there
may be implementations where wchar_t runes are negative (right?).
> in which case (wint_t)w is ok.
Yes, but from the perspective of portable code, it's still
not clear to me that the cast is okay on every possible
implementation of 'wchar_t' and 'wint_t'.
Cheers,
Michael
--
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/
More information about the Libc-alpha
mailing list