[PATCH] Fix newlib/testsuite/newlib.wctype/twctype.c compilation for targets with a 16-bit wint_t.
Jan Dubiec <[email protected]> Mon, 13 Jul 2026 02:40:42 +0200
| Newsgroups | gmane.comp.lib.newlib |
|---|---|
| Message-ID | <[email protected]> |
When the test case is compiled for a target with a 16-bit wint_t, the
compiler emits the two warnings shown below, causing the test to fail. The
code assumes that wint_t is 32 bits wide, which is not always the case.
This patch fixes the issue.
h8300-elf-gcc /mnt/Works/newlib/newlib/testsuite/newlib.wctype/twctype.c -I/mnt/Works/newlib/newlib/testsuite/include -lm -o /mnt/Works/xcomp/build-newlib-h8300-linux/h8300-elf/newlib/testsuite/twctype.x
In file included from /mnt/Works/newlib/newlib/testsuite/newlib.wctype/twctype.c:7:
/mnt/Works/newlib/newlib/testsuite/newlib.wctype/twctype.c: In function 'main':
/mnt/Works/newlib/newlib/testsuite/newlib.wctype/twctype.c:42:23: warning: unsigned conversion from 'long int' to 'wint_t' {aka 'unsigned int'} changes value from '120782' to '55246' [-Woverflow]
42 | CHECK (iswalnum(0x1d7ce));
| ^~~~~~~
/mnt/Works/newlib/newlib/testsuite/include/check.h:5:9: note: in definition of macro 'CHECK'
5 | if (!(a)) \
| ^
/mnt/Works/newlib/newlib/testsuite/newlib.wctype/twctype.c:43:24: warning: unsigned conversion from 'long int' to 'wint_t' {aka 'unsigned int'} changes value from '120832' to '55296' [-Woverflow]
43 | CHECK (!iswalnum(0x1d800));
| ^~~~~~~
/mnt/Works/newlib/newlib/testsuite/include/check.h:5:9: note: in definition of macro 'CHECK'
5 | if (!(a)) \
| ^
Signed-off-by: Jan Dubiec <[email protected]>
---
newlib/testsuite/newlib.wctype/twctype.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/newlib/testsuite/newlib.wctype/twctype.c b/newlib/testsuite/newlib.wctype/twctype.c
index 95be74d63..2275bf44d 100644
--- a/newlib/testsuite/newlib.wctype/twctype.c
+++ b/newlib/testsuite/newlib.wctype/twctype.c
@@ -39,8 +39,13 @@ int main()
setlocale (LC_CTYPE, "C-UTF-8");
CHECK (iswalpha(0x0967));
CHECK (!iswalpha(0x128e));
+#if __SIZEOF_WINT_T__ > 2
+ /* These two lines may cause compilation warnings on targets
+ where wint_t is 16 bits wide, which in turn causes the test
+ case to fail. */
CHECK (iswalnum(0x1d7ce));
CHECK (!iswalnum(0x1d800));
+#endif
CHECK (iswcntrl(0x007f));
CHECK (!iswcntrl(0x2027));
CHECK (iswdigit(L'2'));
--
2.54.0