diff options
Diffstat (limited to 'lib/wmemcmp-impl.h')
-rw-r--r-- | lib/wmemcmp-impl.h | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/wmemcmp-impl.h b/lib/wmemcmp-impl.h index 2b8125fe26..6148220de7 100644 --- a/lib/wmemcmp-impl.h +++ b/lib/wmemcmp-impl.h @@ -27,8 +27,9 @@ wmemcmp (const wchar_t *s1, const wchar_t *s2, size_t n) n--; continue; } - /* Note that wc1 and wc2 each have at most 31 bits. */ - return (int)wc1 - (int)wc2; + /* ISO C requires wmemcmp to work with all wchar_t values. + We cannot assume that wc1 and wc2 are in the range 0..INT_MAX. */ + return _GL_CMP (wc1, wc2); /* > 0 if wc1 > wc2, < 0 if wc1 < wc2. */ } return 0; |