User account creation filtered due to spam.

Bug 13598 - enc_filebuf doesn't work
Summary: enc_filebuf doesn't work
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: libstdc++ (show other bugs)
Version: 3.4.0
: P2 minor
Target Milestone: 3.4.1
Assignee: Benjamin Kosnik
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-01-07 11:13 UTC by Pétur Runólfsson
Modified: 2004-05-24 21:25 UTC (History)
1 user (show)

See Also:
Host: i686-pc-linux-gnu
Target: i686-pc-linux-gnu
Build: i686-pc-linux-gnu
Known to work:
Known to fail:
Last reconfirmed: 2004-03-26 15:25:55


Attachments
Test case (317 bytes, text/plain)
2004-01-07 11:14 UTC, Pétur Runólfsson
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Pétur Runólfsson 2004-01-07 11:13:18 UTC
Although enc_filebuf now compiles (PR 13189), it's not possible to do any
actual IO with it.

The problem seems to be that basic_filebuf assumes that state_type is
assignable, but __enc_traits isn't. Although operator= is defined for
__enc_traits, t = u doesn't result in t being equivalent to u, since
it doesn't copy the iconv_t members (_M_*_desc):

    // Need assignment operator as well.
    __enc_traits&
    operator=(const __enc_traits& __obj)
    {
      strncpy(_M_int_enc, __obj._M_int_enc, _S_max_size);
      strncpy(_M_ext_enc, __obj._M_ext_enc, _S_max_size);
      _M_in_desc = 0;
      _M_out_desc = 0;
      _M_ext_bom = __obj._M_ext_bom;
      _M_int_bom = __obj._M_int_bom;
      return *this;
    }

(Note that there is a memory leak here if _M_in_desc or _M_out_desc are
non-null.)
Comment 1 Pétur Runólfsson 2004-01-07 11:14:30 UTC
Created attachment 5426 [details]
Test case
Comment 2 Benjamin Kosnik 2004-03-26 15:25:54 UTC
Mine.
Comment 3 Benjamin Kosnik 2004-05-24 21:25:08 UTC
Fixed.

2004-03-27  Benjamin Kosnik  <bkoz@redhat.com>

	libstdc++ PR/13598
	* config/locale/ieee_1003.1-2001/codecvt_specializations.h
	(__enc_traits::_M_destroy): New.
	(__enc_traits::~__enc_traits): Use it.
	(__enc_traits::operator=): Use _M_destroy, _M_init.
	(__enc_traits::__enc_traits): Same.

2004-03-27  Petur Runolfsson  <peturr02@ru.is>

	* testsuite/ext/enc_filebuf/char/13598.cc: New.