From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6409 invoked by alias); 6 Jan 2003 09:26:02 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 6385 invoked by uid 71); 6 Jan 2003 09:26:01 -0000 Resent-Date: 6 Jan 2003 09:26:01 -0000 Resent-Message-ID: <20030106092601.6384.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org Resent-Reply-To: gcc-gnats@gcc.gnu.org, peturr02@ru.is Received: (qmail 6158 invoked by uid 61); 6 Jan 2003 09:24:15 -0000 Message-Id: <20030106092415.6157.qmail@sources.redhat.com> Date: Mon, 06 Jan 2003 09:26:00 -0000 From: peturr02@ru.is Reply-To: peturr02@ru.is To: gcc-gnats@gcc.gnu.org X-Send-Pr-Version: gnatsweb-2.9.3 (1.1.1.1.2.31) Subject: libstdc++/9182: basic_filebuf<> does not report errors in codecvt<>::out X-SW-Source: 2003-01/txt/msg00315.txt.bz2 List-Id: >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 #include #include template class errorcvt : public std::codecvt { typedef std::codecvt 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 int main() { std::locale loc; loc = std::locale(loc, new errorcvt); loc = std::locale(loc, new errorcvt); 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; }