This fixes warnings when building libc++, like these:
libcxx/include/locale:1198:18: warning: array subscript is of type 'char'
[-Wchar-subscripts]
if (!isxdigit_l(*__ns, _LIBCPP_GET_C_LOCALE))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/ctype.h:211:41: note: expanded from macro '__chvalidchk'
#define __chvalidchk(a,b) (__PCTYPE_FUNC[(a)] & (b))
^~~~
include/ctype.h:212:121: note: expanded from macro '_chvalidchk_l'
#define _chvalidchk_l(_Char,_Flag,_Locale) (!_Locale ?
__chvalidchk(_Char,_Flag) : ((_locale_t)_Locale)->locinfo->pctype[_Char] &
(_Flag))
^~~~~~
If the char would happen to be >= 0x80 (i.e. negative) this would also
read outside of the bounds of the arrays.
Signed-off-by: Martin Storsjö <[email protected]>
---
mingw-w64-headers/crt/ctype.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/mingw-w64-headers/crt/ctype.h b/mingw-w64-headers/crt/ctype.h
index 44629e1..5bd5643 100644
--- a/mingw-w64-headers/crt/ctype.h
+++ b/mingw-w64-headers/crt/ctype.h
@@ -208,8 +208,8 @@ int __cdecl iswblank(wint_t _C);
_CRTIMP int __cdecl ___mb_cur_max_func(void);
#endif
-#define __chvalidchk(a,b) (__PCTYPE_FUNC[(a)] & (b))
-#define _chvalidchk_l(_Char,_Flag,_Locale) (!_Locale ?
__chvalidchk(_Char,_Flag) : ((_locale_t)_Locale)->locinfo->pctype[_Char] &
(_Flag))
+#define __chvalidchk(a,b) (__PCTYPE_FUNC[(unsigned char)(a)] & (b))
+#define _chvalidchk_l(_Char,_Flag,_Locale) (!_Locale ?
__chvalidchk(_Char,_Flag) : ((_locale_t)_Locale)->locinfo->pctype[(unsigned
char)_Char] & (_Flag))
#define _ischartype_l(_Char,_Flag,_Locale) (((_Locale)!=NULL &&
(((_locale_t)(_Locale))->locinfo->mb_cur_max) > 1) ?
_isctype_l(_Char,(_Flag),_Locale) : _chvalidchk_l(_Char,_Flag,_Locale))
#define _isalpha_l(_Char,_Locale) _ischartype_l(_Char,_ALPHA,_Locale)
#define _isupper_l(_Char,_Locale) _ischartype_l(_Char,_UPPER,_Locale)
--
2.7.4
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public