[PATCH] libstdc++: Fix handling of surrogate CP in codecvt [PR108976]

Dimitrij Mijoski dmjpp@hotmail.com
Mon Mar 20 17:45:47 GMT 2023


On Mon, 2023-03-20 at 15:21 +0000, Jonathan Wakely wrote:
> 
> Thanks, the patch looks OK to my uninformed eye, but I'm seeing a new
> regression:
> 
> /home/jwakely/src/gcc/gcc/libstdc++-
> v3/testsuite/22_locale/codecvt/codecvt_utf16/79980.cc:86: void
> test06(): Assertion 'result == u"from_bytes failed"' failed.
> FAIL: 22_locale/codecvt/codecvt_utf16/79980.cc execution test

Most likely this regression appears because the change related to the
case when odd number of bytes are given to std::codecvt_utf16::in().
The old test 79980.cc:86: void test06() is probably wrong and it should
be changed.


> Also, I see that libc++ fails some of your new tests the same way as
> current libstdc++ does:
> 
> unicode: /home/jwakely/src/gcc/gcc/libstdc++-
> v3/testsuite/22_locale/codecvt/codecvt_unicode.h:298: void
> utf8_to_utf32_in_error(const std::codecvt<InternT, ExternT,
> mbstate_t> &) [InternT = char32_t, ExternT = char]: Assertion `res ==
> cvt.error' failed.
> Aborted (core dumped)
> 
> Does that mean they have the same problem? Or is the test wrong? Or
> is your patch implementing something that contradicts the
> requirements of the standard? I think it's that libc++ has the same
> handling of surrogates, but I'd like to be sure that's right.

See bug https://github.com/llvm/llvm-project/issues/60177 . It can be
reproduced with the testsuite codecvt_unicode without this patch, it is
not related to surrogates. GCC had that bug too but I already fixed it
with my previous big patch on the codecvts.


More information about the Libstdc++ mailing list