public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: libstdc++/9182: basic_filebuf<> does not report errors in codecvt<>::out
@ 2003-03-08 14:04 paolo
  0 siblings, 0 replies; 3+ messages in thread
From: paolo @ 2003-03-08 14:04 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, paolo, peturr02

Synopsis: basic_filebuf<> does not report errors in codecvt<>::out

State-Changed-From-To: analyzed->closed
State-Changed-By: paolo
State-Changed-When: Sat Mar  8 14:04:53 2003
State-Changed-Why:
    Fixed for 3.3 and 3.4.

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=9182


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

* Re: libstdc++/9182: basic_filebuf<> does not report errors in codecvt<>::out
@ 2003-03-01 17:50 paolo
  0 siblings, 0 replies; 3+ messages in thread
From: paolo @ 2003-03-01 17:50 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, nobody, paolo, peturr02

Synopsis: basic_filebuf<> does not report errors in codecvt<>::out

Responsible-Changed-From-To: unassigned->paolo
Responsible-Changed-By: paolo
Responsible-Changed-When: Sat Mar  1 17:50:51 2003
Responsible-Changed-Why:
    Patching.
State-Changed-From-To: open->analyzed
State-Changed-By: paolo
State-Changed-When: Sat Mar  1 17:50:51 2003
State-Changed-Why:
    Confirmed.

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=9182


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

* libstdc++/9182: basic_filebuf<> does not report errors in codecvt<>::out
@ 2003-01-06  9:26 peturr02
  0 siblings, 0 replies; 3+ messages in thread
From: peturr02 @ 2003-01-06  9:26 UTC (permalink / raw)
  To: gcc-gnats


>Number:         9182
>Category:       libstdc++
>Synopsis:       basic_filebuf<> does not report errors in codecvt<>::out
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Jan 06 01:26:00 PST 2003
>Closed-Date:
>Last-Modified:
>Originator:     peturr02@ru.is
>Release:        gcc-3.2.1
>Organization:
>Environment:
Red Hat Linux 8.0
>Description:
basic_filebuf<>::sync and overflow do not write out any characters if codecvt<>::out returns error, but they still return success (as if the buffers had been written successfully).
>How-To-Repeat:
See attachment
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: text/plain; name="errorbug.cc"
Content-Disposition: inline; filename="errorbug.cc"

#include <locale>
#include <cwchar>
#include <fstream>

template <typename InternT, typename ExternT = char,
	  typename StateT = std::mbstate_t>
class errorcvt : public std::codecvt<InternT, ExternT, StateT>
{
	typedef std::codecvt<InternT, ExternT, StateT> Base;

public:
	explicit errorcvt(std::size_t refs = 0)
		: Base(refs)
		{
		}

protected:
	virtual std::codecvt_base::result
	do_out(StateT&, const InternT* from, const InternT*,
	       const InternT*& from_next, ExternT* to, ExternT*,
	       ExternT*& to_next) const
		{
			from_next = from;
			to_next = to;
			return error;
		}

	virtual bool do_always_noconv() const throw()
		{
			return false;
		}
};

#undef NDEBUG
#include <cassert>

int main()
{
	std::locale loc;
	loc = std::locale(loc, new errorcvt<char>);
	loc = std::locale(loc, new errorcvt<wchar_t>);

	std::filebuf fbuf1;
	fbuf1.pubimbue(loc);
	//fbuf1.pubsetbuf(0, 0);
	fbuf1.open("tmp", std::ios_base::out | std::ios_base::trunc);
	// Write some characters, should fail as nothing gets written
	// to the file.
	int n = fbuf1.sputn("abcd", 4); // Should fail if unbuffered
	int r = fbuf1.pubsync(); // Should fail if buffered
	fbuf1.close();

	// Verify that file is empty
	std::filebuf fbuf2;
	fbuf2.open("tmp", std::ios_base::in);
	assert(fbuf2.sgetc() == std::filebuf::traits_type::eof());

	// Either sputn or pubsync or both should have failed
	assert(n < 4 || r != 0);

	return 0;
}


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

end of thread, other threads:[~2003-03-08 14:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-03-08 14:04 libstdc++/9182: basic_filebuf<> does not report errors in codecvt<>::out paolo
  -- strict thread matches above, loose matches on Subject: below --
2003-03-01 17:50 paolo
2003-01-06  9:26 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).