public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: libstdc++/9168: codecvt<char, char, mbstate_t> overwrites output buffers
@ 2003-01-05 8:26 paolo
0 siblings, 0 replies; 3+ messages in thread
From: paolo @ 2003-01-05 8:26 UTC (permalink / raw)
To: gcc-bugs, gcc-prs, paolo, peturr02
Synopsis: codecvt<char, char, mbstate_t> overwrites output buffers
State-Changed-From-To: analyzed->closed
State-Changed-By: paolo
State-Changed-When: Sun Jan 5 00:26:46 2003
State-Changed-Why:
Fixed for 3.2.2 amd 3.3.
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=9168
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: libstdc++/9168: codecvt<char, char, mbstate_t> overwrites output buffers
@ 2003-01-04 15:44 paolo
0 siblings, 0 replies; 3+ messages in thread
From: paolo @ 2003-01-04 15:44 UTC (permalink / raw)
To: gcc-bugs, gcc-prs, nobody, paolo, peturr02
Synopsis: codecvt<char, char, mbstate_t> overwrites output buffers
Responsible-Changed-From-To: unassigned->paolo
Responsible-Changed-By: paolo
Responsible-Changed-When: Sat Jan 4 07:44:54 2003
Responsible-Changed-Why:
Patching.
State-Changed-From-To: open->analyzed
State-Changed-By: paolo
State-Changed-When: Sat Jan 4 07:44:54 2003
State-Changed-Why:
Confirmed.
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=9168
^ permalink raw reply [flat|nested] 3+ messages in thread
* libstdc++/9168: codecvt<char, char, mbstate_t> overwrites output buffers
@ 2003-01-04 9:56 peturr02
0 siblings, 0 replies; 3+ messages in thread
From: peturr02 @ 2003-01-04 9:56 UTC (permalink / raw)
To: gcc-gnats
>Number: 9168
>Category: libstdc++
>Synopsis: codecvt<char, char, mbstate_t> overwrites output buffers
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sat Jan 04 01:56:00 PST 2003
>Closed-Date:
>Last-Modified:
>Originator: peturr02@ru.is
>Release: gcc-3.2.1
>Organization:
>Environment:
Red Hat Linux 8.0
>Description:
codecvt<char, char, mbstate_t>::in and codecvt<char, char, mbstate_t>::out copy the input buffer to the output buffer, but should not do so.
According to the resolution to library defect report 19 <http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/lwg-defects.html#19>, codecvt<>::in and codecvt<>::out should not overwrite the output buffers when they return noconv:
"If returns noconv [...] there are no changes to the values in [to, to_limit)."
The resolution to defect report 305 is also clear:
"codecvt<char,char,mbstate_t> stores no characters."
>How-To-Repeat:
See attachment
>Fix:
Remove the memcpy calls from in and out.
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: text/plain; name="defect19.cc"
Content-Disposition: inline; filename="defect19.cc"
#include <locale>
#include <cwchar>
#include <cstdlib>
#include <cstring>
#include <algorithm>
int main()
{
typedef std::codecvt<char, char, std::mbstate_t> codecvt_type;
std::mbstate_t state;
std::codecvt_base::result res;
const char* from = "foo";
const char* from_end = from + strlen(from);
const char* from_next;
const std::size_t to_size = 256;
char to[to_size];
char* to_end = to + to_size;
char* to_next;
std::mbstate_t state0;
std::memset(&state0, 0, sizeof(state0));
std::memset(to, 'X', to_size);
std::memset(&state, 0, sizeof(state));
std::locale loc (std::locale::classic());
const codecvt_type& cvt = std::use_facet<codecvt_type>(loc);
assert(cvt.always_noconv());
res = cvt.in(state, from, from_end, from_next,
to, to_end, to_next);
assert(res == std::codecvt_base::noconv);
assert(to_next == to);
assert(std::memcmp(&state, &state0, sizeof(state)) == 0);
assert(std::count(to, to_end, 'X') == to_size);
res = cvt.out(state, from, from_end, from_next,
to, to_end, to_next);
assert(res == std::codecvt_base::noconv);
assert(to_next == to);
assert(std::memcmp(&state, &state0, sizeof(state)) == 0);
assert(std::count(to, to_end, 'X') == to_size);
return 0;
}
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2003-01-05 8:26 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-01-05 8:26 libstdc++/9168: codecvt<char, char, mbstate_t> overwrites output buffers paolo
-- strict thread matches above, loose matches on Subject: below --
2003-01-04 15:44 paolo
2003-01-04 9:56 peturr02
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).