From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20406 invoked by alias); 15 Jan 2003 10:26:01 -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 20385 invoked by uid 71); 15 Jan 2003 10:26:01 -0000 Resent-Date: 15 Jan 2003 10:26:01 -0000 Resent-Message-ID: <20030115102601.20384.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 18604 invoked by uid 61); 15 Jan 2003 10:19:33 -0000 Message-Id: <20030115101933.18603.qmail@sources.redhat.com> Date: Wed, 15 Jan 2003 10: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++/9320: Incorrect usage of traits_type::int_type in stdio_filebuf X-SW-Source: 2003-01/txt/msg00934.txt.bz2 List-Id: >Number: 9320 >Category: libstdc++ >Synopsis: Incorrect usage of traits_type::int_type in stdio_filebuf >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: sw-bug >Submitter-Id: net >Arrival-Date: Wed Jan 15 02:26:01 PST 2003 >Closed-Date: >Last-Modified: >Originator: peturr02@ru.is >Release: gcc-3.2.1 >Organization: >Environment: Red Hat Linux 8.0 >Description: The constructors for __gnu_cxx::stdio_filebuf<> take an int_type parameter that is used to specify a buffer size. However, stdio_filebuf<> has the same template parameters as basic_filebuf<>, so I assume that the same constraits are set on int_type, i.e. int_type is not required to be an integer type (or convertible to one). In any case this is a bad example for any users wishing to derive their own classes from basic_streambuf<> or basic_filebuf<>. >How-To-Repeat: See attachment (should compile, but doesn't). >Fix: Use streamsize instead of int_type for the constructors. >Release-Note: >Audit-Trail: >Unformatted: ----gnatsweb-attachment---- Content-Type: text/plain; name="inttypebug.cc" Content-Disposition: inline; filename="inttypebug.cc" #include struct MyChar { int val; }; struct MyInt { long val; }; class MyState { }; class MyTraits { public: typedef MyChar char_type; typedef MyInt int_type; typedef std::streampos pos_type; typedef std::streamoff off_type; typedef MyState state_type; static void assign(char_type& __c1, const char_type& __c2); static bool eq(const char_type& __c1, const char_type& __c2); static bool lt(const char_type& __c1, const char_type& __c2); static int compare(const char_type* __s1, const char_type* __s2, size_t __n); static size_t length(const char_type* __s); static const char_type* find(const char_type* __s, size_t __n, const char_type& __a); static char_type* move(char_type* __s1, const char_type* __s2, size_t __n); static char_type* copy(char_type* __s1, const char_type* __s2, size_t __n); static char_type* assign(char_type* __s, size_t __n, char_type __a); static char_type to_char_type(const int_type& __c); static int_type to_int_type(const char_type& __c); static bool eq_int_type(const int_type& __c1, const int_type& __c2); static int_type eof(); static int_type not_eof(const int_type& __c); }; template class std::basic_streambuf; template class std::basic_filebuf; template class __gnu_cxx::stdio_filebuf; int main() { typedef __gnu_cxx::stdio_filebuf buf_type; buf_type buf1 (static_cast(0), std::ios_base::in); buf_type buf2 (0, std::ios_base::in, false, MyInt()); return 0; }