Signedness of wchar_t and wint_t leads to problems with gcc -Wsign-conversion

Igor Liferenko igor.liferenko@gmail.com
Wed Nov 23 05:50:00 GMT 2016


Hi all,

Can you please say if the typecasts in the following two programs are valid?
(I just replaced wint_t and wchar_t to their actual meaning in glibc)

    #include <locale.h>
    #include <wchar.h>
    int main(void)
    {
      setlocale(LC_CTYPE, "en_US.UTF-8");
      unsigned int wc;
      wc = getwchar();
      putwchar((int) wc);
    }

--

    #include <locale.h>
    #include <wchar.h>
    #include <wctype.h>
    int main(void)
    {
      setlocale(LC_CTYPE, "en_US.UTF-8");
      int wc;
      wc = L'ÿ';
      if (iswlower((unsigned int) wc)) return 0;
      return 1;
    }


Igor



More information about the Libc-alpha mailing list