public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/37475]  New: codecvt::do_in/do_out functions return "ok" when the output sequence has zero length
@ 2008-09-11  9:34 tsyvarev at ispras dot ru
  2008-09-11  9:36 ` [Bug libstdc++/37475] " tsyvarev at ispras dot ru
  2008-09-11 10:32 ` paolo dot carlini at oracle dot com
  0 siblings, 2 replies; 16+ messages in thread
From: tsyvarev at ispras dot ru @ 2008-09-11  9:34 UTC (permalink / raw)
  To: gcc-bugs

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).

andrew@Ubuntu:/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.
andrew@Ubuntu:/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


^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2024-06-27 11:10 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-37475-4@http.gcc.gnu.org/bugzilla/>
2015-09-02 11:15 ` [Bug libstdc++/37475] [DR 382] codecvt::do_in/do_out functions return "ok" when the output sequence has zero length redi at gcc dot gnu.org
2021-02-08 18:59 ` kristian.spangsege at gmail dot com
2024-06-11 14:02 ` kristian.spangsege at gmail dot com
2024-06-11 14:03 ` kristian.spangsege at gmail dot com
2024-06-11 14:43 ` redi at gcc dot gnu.org
2024-06-11 15:09 ` [Bug libstdc++/37475] " redi at gcc dot gnu.org
2024-06-11 15:12 ` redi at gcc dot gnu.org
2024-06-11 15:22 ` redi at gcc dot gnu.org
2024-06-11 18:45 ` kristian.spangsege at gmail dot com
2024-06-12 20:35 ` redi at gcc dot gnu.org
2024-06-17 12:44 ` kristian.spangsege at gmail dot com
2024-06-17 15:55 ` redi at gcc dot gnu.org
2024-06-27 11:07 ` cvs-commit at gcc dot gnu.org
2024-06-27 11:10 ` redi at gcc dot gnu.org
2008-09-11  9:34 [Bug libstdc++/37475] New: " tsyvarev at ispras dot ru
2008-09-11  9:36 ` [Bug libstdc++/37475] " tsyvarev at ispras dot ru
2008-09-11 10:32 ` paolo dot carlini at oracle dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).