Boost logo

Boost :

From: SourceForge.net (noreply_at_[hidden])
Date: 2006-08-02 22:39:47


Bugs item #1533595, was opened at 2006-08-03 04:39
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=107586&aid=1533595&group_id=7586

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: serialization
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Thomas Pintaric (pintaric)
Assigned to: Robert Ramey (ramey)
Summary: serializing empty vectors triggers STL assertion failure (VC

Initial Comment:
Serializing empty vectors triggers an STL assertion
failure (VC++ 8.0).

Test case:
==========

typedef std::vector<int> vec_t;
vec_t v; // empty vector
{
  std::ofstream ofs("test.dat");
  boost::archive::binary_oarchive oa(ofs);
  oa << v; // triggers runtime assertion
}

The assertion is caused by line 31 in
serialization/detail/get_data.hpp (note that vector v
is empty):
[0031] return &(v[0]);

Proposed fix:
=============

Index: oarchive.hpp
===================================================================
RCS file:
/cvsroot/boost/boost/boost/archive/array/oarchive.hpp,v
retrieving revision 1.3
diff -r1.3 oarchive.hpp
73c73
< * this->This() <<
serialization::make_array(serialization::detail::get_data(t),t.size());

---
>     if(count) * this->This() <<
serialization::make_array(serialization::detail::get_data(t),t.size());
Index: iarchive.hpp
===================================================================
RCS file:
/cvsroot/boost/boost/boost/archive/array/iarchive.hpp,v
retrieving revision 1.3
diff -r1.3 iarchive.hpp
77c77
<     * this->This() >>
serialization::make_array(serialization::detail::get_data(t),t.size());
---
>     if(count) * this->This() >>
serialization::make_array(serialization::detail::get_data(t),t.size());
----------------------------------------------------------------------
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=107586&aid=1533595&group_id=7586
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Boost-bugs mailing list
Boost-bugs_at_[hidden]
https://lists.sourceforge.net/lists/listinfo/boost-bugs

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk