[Bug libstdc++/86419] codecvt<char16_t, ...>::in() and out() incorrectly return ok in some cases.
dmjpp at hotmail dot com
gcc-bugzilla@gcc.gnu.org
Wed Sep 2 00:41:17 GMT 2020
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86419
--- Comment #5 from Dimitrij Mijoski <dmjpp at hotmail dot com> ---
I think I found where the bug lies. It lies in
1. line 557 of the file c++11/codecvt.cc
https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=libstdc%2B%2B-v3/src/c%2B%2B11/codecvt.cc;h=0311b15177d0439757e0347f7934b5a09b78f8e3;hb=HEAD#l557
.
The return of the function utf16_in() should be:
return from.size() ? codecvt_base::partial : codecvt_base::ok;
The bug is triggered because the loop exists because t.size() is zero.
from.size() should be checked.
2. line 579 of the same file
https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=libstdc%2B%2B-v3/src/c%2B%2B11/codecvt.cc;h=0311b15177d0439757e0347f7934b5a09b78f8e3;hb=HEAD#l579
578 if (from.size() < 2)
579 return codecvt_base::ok; // stop converting at this point
Should be
578 if (from.size() < 2)
579 return codecvt_base::partial; // stop converting at this
point
More information about the Gcc-bugs
mailing list