This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libc/20639] Inconsistency in definitions of fputwc(), putwc() and putwchar() in glibc


https://sourceware.org/bugzilla/show_bug.cgi?id=20639

--- Comment #2 from Igor Liferenko <igor.liferenko at gmail dot com> ---
Hi,

    That's because the C standard defines them that way.

Not clear how this helps to get rid of the warnings.

    You need to check for WEOF first anyway.

As far as I understand, by this you mean that we have to save the value in an
intermediate variable. Alas, this does not help to remove the warnings
either... These are the examples which check for WEOF with wint_t and wchar_t:

Example 1:

    #include <locale.h>
    #include <wchar.h>
    int main(void)
    {
      setlocale(LC_CTYPE, "en_US.UTF-8");
      wchar_t c = getwchar();
      if (c != WEOF)
        putwchar(c);
      return 0;
    }

Output 1:

    bug.c: In function ‘main’:
    bug.c:6:15: warning: conversion to ‘wchar_t {aka int}’ from ‘wint_t {aka
unsigned int}’ may change the sign of the result [-Wsign-conversion]
       wchar_t c = getwchar();
                   ^~~~~~~~

Example 2:

    #include <locale.h>
    #include <wchar.h>
    int main(void)
    {
      setlocale(LC_CTYPE, "en_US.UTF-8");
      wint_t c = getwchar();
      if (c != WEOF)
        putwchar(c);
      return 0;
    }

Output 2:

    bug.c: In function ‘main’:
    bug.c:8:14: warning: conversion to ‘wchar_t {aka int}’ from ‘wint_t {aka
unsigned int}’ may change the sign of the result [-Wsign-conversion]
         putwchar(c);
                  ^

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]