The following member functions of the class codecvt<wchar_t, char, mbstate_t>

result in(stateT& state, const externT* from, const externT* from_end, const
externT*& from_next, internT* to, internT* to_limit, internT*& to_next) const

and

result out(stateT& state, const internT* from, const internT* from_end, const
internT*& from_next, externT* to, externT* to_limit, externT*& to_next) const

return "ok" if (to==to_limit) but (from < from_end), that is, when the output
sequence contains no elements but the input sequence is not empty. 

However, as appears from the description of the functions' return values
(22.2.1.5.2 p4), "partial" should be returned instead:

ok - completed the conversion
partial - not all source characters converted
error - encountered a character in [from,from_end) that it could not convert
noconv - internT and externT are the same type, and input sequence is identical
to converted sequence

Note that these functions do return "partial" if the output sequence is not
empty but still not large enough to contain all converted characters from the
input sequence, that is, if 
0< (to_limit - to) < (from_end - from).

[EMAIL PROTECTED]:/mnt/hgfs/shared/temp/test$ g++ -Wall test.cpp && ./a.out
Calls do_out() function when size of input sequenceis 2, output - 1:
do_out() returns partial.
Calls do_out() function when size of input sequenceis 2, output - 0:
do_out() returns ok.
Calls do_in() function when size of input sequenceis 2, output - 1:
do_in() returns partial.
Calls do_in() function when size of input sequenceis 2, output - 0:
do_in() returns ok.
[EMAIL PROTECTED]:/mnt/hgfs/shared/temp/test$ g++ --version
g++ (GCC) 4.1.2 (Ubuntu 4.1.2-0ubuntu4)
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


-- 
           Summary: codecvt::do_in/do_out functions return "ok" when the
                    output sequence has zero length
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: tsyvarev at ispras dot ru


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37475

Reply via email to