On Fri, 11 Jun 2021, Jacek Caban wrote:

On 6/11/21 3:51 AM, Liu Hao wrote:
在 6/11/21 4:09 AM, Martin Storsjö 写道:
Since the initial commit of mingw-w64, there's a call (in a
constructor in crt/charmax.c, pulled in via the mingw_initcharmax
variable) to __lconv_init(), which reconfigures the CRT's lconv
info to unsigned char mode - but there's no explanation for why
this is the case.

The fact that mingw-w64 initializes lconv info this way breaks
a test in llvm's libc++ (where it expects lconv's frac_digits to
be intialized to CHAR_MAX, not UCHAR_MAX). This also differs to
how MSVC environments behave, where they are initialized to
CHAR_MAX.

So unless there's a clear known reason why we'd initialize it
to unsigned char mode, revert to the same behaviour as MSVC has.

Signed-off-by: Martin Storsjö <mar...@martin.st>
---
  mingw-w64-crt/crt/crtexe.c | 2 --
  1 file changed, 2 deletions(-)



This patch looks good to me.


Looks good to me as well. I'm not sure if we want to keep charmax.c at all, or change default _charmax value, but it doesn't need to block this patch.

Thanks, pushed that now.

If I understand things correctly, the backstory is that with MSVC, you can pass an option (/J) to the compiler to request 'char' to be an unsigned data type. If you pass this option, then the compiler defines _CHAR_UNSIGNED. If you have _CHAR_UNSIGNED define and include locale.h (in MSVC 2013 and earlier), this does some sort of header trick which causes an undefined reference to the _charmax symbol, which then would pull in something equivalent to our charmax.c. In UCRT, this trick has been renamed and uses the symbol __do_unsigned_char_lconv_initialization instead of _charmax.

These tricks aren't hooked up in mingw-w64 headers, and our chars default to signed, so this is indeed the right default, but if we want to follow suit we'd need to do something similar. But I'm not sure if changing to unsigned chars is a setting we should spend extra effort on actually supporting anyway...

// Martin

_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to