在 2025-6-8 00:21, Kirill Makurin 写道:
I guess sticking to range [0,255] is our best choice.

I attached patches.


Mostly these look good to me. However I get errors from libc++ testsuite:

   
https://github.com/lhmouse/mingw-w64/actions/runs/15650737822/job/44095645474#step:7:13365

which failed at this, which can by producedby installing mingw-w64 CRT with the first patch and compiling the testcase with `clang++ -static`:

   std::locale l;
   typedef std::ctype_byname<wchar_t> F;
   std::locale ll(l, new F("C"));
   const F& f = std::use_facet<F>(ll);
   assert(f.widen(char(-5)) == L'\u00fb');


And here's backtrace:

   #0  0x00007ff657205139 in btowc (c=-5) at misc/btowc.c:16
   #1  0x00007ff6571fcd61 in std::__1::__locale::__btowc(int, 
std::__1::__locale::__locale_t) ()
   #2  0x00007ff6571dda9a in std::__1::ctype_byname<wchar_t>::do_widen(char) 
const ()
#3 0x00007ff6571b19ac in std::__1::ctype<wchar_t>::widen[abi:ne200100](char) const (this=0x5b9c40, __c=-5 '\373') at C:/MSYS64/clang64/include/c++/v1/__locale:490
   #4  0x00007ff6571b1884 in main () at test.cc:37


Here we can see the parameter `c` of type `int` is a sign-extension of the 
argument, so I think this

   if (cp == 0)
     return (unsigned) c <= 0xFF ? c : WEOF;

is being skeptical. What if we blindly truncate `c`, just like the code beneath 
it:

   if (cp == 0)
     return (unsigned char) c;



--
Best regards,
LIU Hao

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature

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

Reply via email to