Could someone apply this patch? Right now, CHAR_MIN and CHAR_MAX will be incorrect if gcc is invoked with the -funsigned-char option. This patch fixes it to comply with section 5.2.4.2.1.2 of C11 (N1570), which says:
If the value of an object of type char is treated as a signed integer when used in an expression, [...cut...]. Otherwise, the value of CHAR_MIN shall be 0 and the value of CHAR_MAX shall be the same as that of UCHAR_MAX.
I don't actually use -funsigned-char, but I imagine there is legacy code out there that uses it, and would be compiled incorrectly without this patch. We discussed this same patch on August 3. Jacek Caban said:
I'm not sure about this, but it probably makes sense. IMO it would be nice to have it in a separated commit and commented by Kai.
Thanks! --David Grayson
diff --git a/mingw-w64-headers/crt/limits.h b/mingw-w64-headers/crt/limits.h index 73dca2a..f0145df 100644 --- a/mingw-w64-headers/crt/limits.h +++ b/mingw-w64-headers/crt/limits.h @@ -24,8 +24,13 @@ #define SCHAR_MAX 127 #define UCHAR_MAX 0xff +#ifdef __CHAR_UNSIGNED__ +#define CHAR_MIN 0 +#define CHAR_MAX UCHAR_MAX +#else #define CHAR_MIN SCHAR_MIN #define CHAR_MAX SCHAR_MAX +#endif #define MB_LEN_MAX 5 #define SHRT_MIN (-32768)
------------------------------------------------------------------------------
_______________________________________________ Mingw-w64-public mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
