Return-Path: Delivered-To: apmail-incubator-stdcxx-dev-archive@www.apache.org Received: (qmail 26585 invoked from network); 28 Jun 2006 20:58:07 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 28 Jun 2006 20:58:07 -0000 Received: (qmail 96263 invoked by uid 500); 28 Jun 2006 20:58:07 -0000 Delivered-To: apmail-incubator-stdcxx-dev-archive@incubator.apache.org Received: (qmail 96209 invoked by uid 500); 28 Jun 2006 20:58:07 -0000 Mailing-List: contact stdcxx-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: stdcxx-dev@incubator.apache.org Delivered-To: mailing list stdcxx-dev@incubator.apache.org Received: (qmail 96190 invoked by uid 99); 28 Jun 2006 20:58:07 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 28 Jun 2006 13:58:07 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received: from [209.237.227.198] (HELO brutus.apache.org) (209.237.227.198) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 28 Jun 2006 13:58:06 -0700 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id CE955410005 for ; Wed, 28 Jun 2006 20:56:29 +0000 (GMT) Message-ID: <2600698.1151528189843.JavaMail.jira@brutus> Date: Wed, 28 Jun 2006 20:56:29 +0000 (GMT+00:00) From: "Martin Sebor (JIRA)" To: stdcxx-dev@incubator.apache.org Subject: [jira] Created: (STDCXX-243) std::basic_istream::gcount() returns wrong value after a successful peek() MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N std::basic_istream::gcount() returns wrong value after a successful peek() -------------------------------------------------------------------------- Key: STDCXX-243 URL: http://issues.apache.org/jira/browse/STDCXX-243 Project: C++ Standard Library Type: Improvement Components: 27. Input/Output Versions: 4.1.2, 4.1.3 Environment: all Reporter: Martin Sebor Moved from the Rogue Wave bug tracking database: Class/File: istream.cc Fix Priority: Should Fix Long Description: *** Sep 23 1999 9:52AM *** sebor *** Partially resolved - gcount now more consistent with other implementations (still needs to be revisited when WG21 addresses the issue - can't find it on the issues list, though). *** Aug 24 1999 9:51AM *** sebor *** RW implementation of gcount() currently returns 1 after a successful peek(), 0 after an error. That's wrong according to 27.6.1.3, p2, since peek() doesn't extract any characters. The correct behavior is either to have gcount() always return 0 after a peek() or not to have peek() affect gcount() at all. The standard doesn't seem to specify which. To: C++ libraries mailing list Message c++std-lib-6965 Should basic_istream::peek() affect the value returned by basic_istream::gcount()? If it does affect gcount in any way, then clearly it ought to always set gcount to zero. The description in 27.6.1.3 [lib.istream.unformatted], paragraph 27, doesn't say whether peek affects gcount. Another way to phrase this issue: is peek() an unformatted input function? Textually it's located in [lib.istream.unformatted], but that doesn't mean very much since that section also contains several member functions that clearly do not behave as unformatted input functions as described in 27.6.1.3/1. Textual location is not a sufficient guide. Survey: Classic AT&T: peek doesn't affect gcount SGI (MIPSpro 7.3): peek doesn't affect gcount Microsoft 6.0: peek sets gcount to zero. Dietmar: peek sets gcount to zero. others? --Matt Here's a test program. #include #include #include #ifndef CLASSIC_IOSTREAMS #include #include using std::cout; using std::endl; using std::ifstream; using std::ofstream; #else #include #include #endif int main() { // Create a temporary file. char name_buf[L_tmpnam]; const char* name = tmpnam(name_buf); assert(name != 0 && strlen(name) > 0); { ofstream out(name); out << "1234 abcd" << endl; } { ifstream in(name); const int N = 128; char buf[N]; in.read(buf, 6); assert(in.gcount() == 6); assert(strncmp(buf, "1234 a", 6) == 0); // The real point of this test: what about peek and gcount? assert(in.peek() == 'b'); cout << "gcount = " << in.gcount() << endl; } // Destroy the temporary file. remove(name); } -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira