Open llvmbot opened 12 years ago
I think that do_in should behave as below.
As pointed out above, I think that it should return partial, not ok.
cf. http://melpon.org/wandbox/permlink/8Jo9s9qODgywSmtP
This behavior causes llvm/llvm-bugzilla-archive#24929 .
Additionally, if "from" ends with an incomplete multibyte sequence followed by a null byte, "from_next" should point the first byte of an incomplete multibyte sequence, not a null byte.
C++98 (or later) standard 22.2.1.5.2 codecvt virtual functions [lib.locale.codecvt.virtuals] p.2 says, "It always leaves the from_next and to_next pointers pointing one beyond the last element successfully converted."
committed revision 233012 to fix this problem.
I'm going to leave this bug open, though, until I figure what the correct behavior is. The fix merely deals with the error correctly.
assigned to @mclow
Extended Description
When supplied with a partial multibyte input (i.e. a multibyte prefix), codecvt::in() returns codecvt_base::error instead of codecvt_base::partial.
Steps to reproduce:
Expected results: The testcase should print "partial". Actual results: The testcase prints "error".
Additional notes: I've reproduced this bug on both my Mac and Linux systems using the above testcase, which calls codecvt::in() on the first byte of the three-byte UTF-8 string "ℝ".
The C++11 standard (22.4.1.4.2) seems to imply that codecvt_base::partial should be returned, since "additional source elements are needed before another destination element can be produced". However, in the above testcase, libstdc++ 4.7 on my Linux machine returns codecvt_base::ok, so I'm not sure what the correct behavior is.
The code responsible (locale.cpp:1386) seems to have some inverted logic. In particular,
I'm fairly sure this is a bug, however I'm kind of poking around in the dark here, so please correct me if this is the intended behavior.