Bug 13598 - enc_filebuf doesn't work
Bug#: 13598 Product:  gcc Version: 3.4.0
Host: i686-pc-linux-gnu Target: i686-pc-linux-gnu Build: i686-pc-linux-gnu
Status: RESOLVED Severity: minor Priority: P2
Resolution: FIXED Assigned To: bkoz@gcc.gnu.org Reported By: peturrun@gmail.com
Component: libstdc++ Target Milestone: 3.4.1
Summary: enc_filebuf doesn't work
Keywords:  
Opened: 2004-01-07 11:13
Description:   Last confirmed: 2004-03-26 15:25 Opened: 2004-01-07 11:13
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 From Pétur Runólfsson 2004-01-07 11:14 -------
Created an attachment (id=5426) [edit]
Test case

------- Comment #2 From Benjamin Kosnik 2004-03-26 15:25 -------
Mine.

------- Comment #3 From Benjamin Kosnik 2004-05-24 21:25 -------
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.