https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63301
Bug ID: 63301 Summary: inconsistency on wchar_t and wint_t types and sizes for diverse architectures Product: gcc Version: 4.8.3 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: marcos.diaz at tallertechnologies dot com Created attachment 33514 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=33514&action=edit Test to print wchar_t At compiling the attached file with the following command: sparc-rtems4.11-gcc testw_char.c -Wall -Wextra -c The following warning appeared: testw_char.c: In function 'main': testw_char.c:6:2: warning: format '%lc' expects argument of type 'wint_t', but argument 2 has type 'wchar_t' [-Wformat=] printf("%lc", wc); ^ testw_char.c:6:2: warning: format '%lc' expects argument of type 'wint_t', but argument 2 has type 'wchar_t' [-Wformat=] But if we compile the same file with, for example, arm-rtems4.11-gcc we get no warning. At further investigation we saw that the types of the wint_t and wchar_t for this architecture were different: sparc-rtems4.11-gcc testw_char.c -Wall -Wextra -c -E The output is as follows: ... typedef long int wchar_t; typedef unsigned int wint_t; ... (Note that the type of wchar_t is larger than of wint_t) With help from Joel Sherrill in RTEMS we could see that those architectures that issue the warning have inconsistency in the types of wint_t and wchar_t, and the others dont: === arm-rtems4.11-gcc - no warning typedef unsigned int wchar_t; typedef unsigned int wint_t; (this has no warnings). These are the others that Joel detected with the inconsistency: === m68k-rtems4.11-gcc typedef long int wchar_t; typedef unsigned int wint_t; === m32c-rtems4.11-gcc - warning typedef long int wchar_t; typedef unsigned int wint_t; === powerpc-rtems4.11-gcc - warning typedef long int wchar_t; typedef unsigned int wint_t; === sh-rtems4.11-gcc - warning typedef long int wchar_t; typedef unsigned int wint_t; === sparc-rtems4.11-gcc - warning typedef long int wchar_t; typedef unsigned int wint_t; === v850-rtems4.11-gcc - warning typedef long int wchar_t; typedef unsigned int wint_t; The configuration for sparc-rtems4.11-gcc: (the others are similar) Using built-in specs. COLLECT_GCC=sparc-rtems4.11-gcc COLLECT_LTO_WRAPPER=/home/marcos/Desktop/WcharRTEMS/ins-gcc/libexec/gcc/sparc-rtems4.11/4.8.3/lto-wrapper Target: sparc-rtems4.11 Configured with: ../gcc-4.8.3/configure --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=sparc-rtems4.11 --disable-libstdcxx-pch --with-gnu-as --with-gnu-ld --verbose --with-newlib --with-system-zlib --disable-nls --without-included-gettext --disable-win32-registry --enable-version-specific-runtime-libs --disable-lto --enable-newlib-io-c99-formats --enable-newlib-iconv --enable-newlib-iconv-encodings=big5,cp775,cp850,cp852,cp855,cp866,euc_jp,euc_kr,euc_tw,iso_8859_1,iso_8859_10,iso_8859_11,iso_8859_13,iso_8859_14,iso_8859_15,iso_8859_2,iso_8859_3,iso_8859_4,iso_8859_5,iso_8859_6,iso_8859_7,iso_8859_8,iso_8859_9,iso_ir_111,koi8_r,koi8_ru,koi8_u,koi8_uni,ucs_2,ucs_2_internal,ucs_2be,ucs_2le,ucs_4,ucs_4_internal,ucs_4be,ucs_4le,us_ascii,utf_16,utf_16be,utf_16le,utf_8,win_1250,win_1251,win_1252,win_1253,win_1254,win_1255,win_1256,win_1257,win_1258 --enable-threads --disable-plugin --enable-languages=c,c++