This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: basic_ostringstream<unsigned short> causes segmentation faults


On Wed, Apr 24, 2002 at 12:30:22PM +0200, Mads wrote:
> does it make sense to use std::basic_ostringstream<unsigned short>?

In principle, yes.  In practice, you might expect problems with
operator<< and >> overloads.  A better choice would be a struct 
containing an unsigned short.
 
> According to the headerfiles a basic_stringstream has a generic template -
> but template specializations are used for char and wchar_t.
> 
> As the following example shows we get segmentation faults when the generic
> template is used. Defining a char_trait gives the same bug. It seems like
> the pure virtual method do_widen in std::__ctype_abstract_base is called...

For some operations it does need appropriate locale facets, which you 
would have to imbue yourself along with the char_traits specialization.
In their absence you should expect exceptions to be thrown.  I don't 
think you should get segfaults.  

Please enter a bug report.
 
Nathan Myers
ncm at cantrip dot org


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]