Boost C++ Libraries: Ticket #6107: Boost sample source code cant compile .boost1.33.1 and gcc4.1.2 https://svn.boost.org/trac10/ticket/6107 <p> Question about the boost sample program I'm trying to compile the following code example: #include &lt;fstream&gt; #include &lt;boost/archive/text_oarchive.hpp&gt; #include &lt;boost/archive/text_iarchive.hpp&gt; </p> <p> class gps_position { private: </p> <blockquote> <p> friend class boost::serialization::access; template&lt;class Archive&gt; void serialize(Archive &amp; ar, const unsigned int version) { </p> <blockquote> <p> ar &amp; degrees; ar &amp; minutes; ar &amp; seconds; </p> </blockquote> <p> } int degrees; int minutes; float seconds; </p> </blockquote> <p> public: </p> <blockquote> <p> gps_position() { </p> <blockquote> <p> degrees = 0; minutes = 0; seconds = 0.0; </p> </blockquote> <p> }; gps_position(int d, int m, float s) : degrees(d), minutes(m), seconds(s) {} </p> </blockquote> <p> }; </p> <p> class bus_stop { </p> <blockquote> <p> friend class boost::serialization::access; template&lt;class Archive&gt; void serialize(Archive &amp; ar, const unsigned int version) { </p> <blockquote> <p> ar &amp; latitude; ar &amp; longitude; </p> </blockquote> <p> } gps_position latitude; gps_position longitude; </p> </blockquote> <p> public: </p> <blockquote> <p> bus_stop(){ } bus_stop(const gps_position &amp; lat_, const gps_position &amp; long_) : </p> <blockquote> <p> latitude(lat_), longitude(long_) { } </p> </blockquote> <p> virtual ~bus_stop(){ } </p> </blockquote> <p> }; </p> <p> int main() { </p> <blockquote> <p> <em> create and open a character archive for output std::ofstream ofs("busfile"); </em></p> </blockquote> <blockquote> <p> <em> create class instance of gps_position const gps_position latitude(1, 2, 3.3f); const gps_position longitude(4, 5, 6.6f); </em></p> </blockquote> <blockquote> <p> bus_stop stop(latitude, longitude); </p> </blockquote> <blockquote> <p> <em> save data to archive { </em></p> <blockquote> <p> boost::archive::text_oarchive oa(ofs); <em> write class instance to archive oa &lt;&lt; stop; </em></p> </blockquote> <p> } </p> </blockquote> <blockquote> <p> <em> ... sometime later restore class instance of bus_stop to its orginal state bus_stop newstop; { </em></p> <blockquote> <p> <em> create and open an archive for input std::ifstream ifs("busfile", std::ios::binary); boost::archive::text_iarchive ia(ifs); </em> read class state of bus_stop form archive ia &gt;&gt; newstop; </p> </blockquote> <p> } return 0; </p> </blockquote> <p> } </p> <p> With the following command line: g++ -o boostSample demo.cc -lboost_serialization and it throws an compile error: /usr/include/boost/archive/detail/oserializer.hpp: In function ‘void boost::archive::save(Archive&amp;, T&amp;) [with Archive = boost::archive::text_oarchive, T = bus_stop]’: /usr/include/boost/archive/basic_text_oarchive.hpp:78: instantiated from ‘void boost::archive::basic_text_oarchive&lt;Archive&gt;::save_override(T&amp;, int) [with T = bus_stop, Archive = boost::archive::text_oarchive]’ /usr/include/boost/archive/detail/interface_oarchive.hpp:78: instantiated from ‘Archive&amp; boost::archive::detail::interface_oarchive&lt;Archive&gt;::operator&lt;&lt;(T&amp;) [with T = bus_stop, Archive = boost::archive::text_oarchive]’ demo.cc:67: instantiated from here /usr/include/boost/archive/detail/oserializer.hpp:567: error: invalid application of ‘sizeof’ to incomplete type ‘boost::STATIC_ASSERTION_FAILURE&lt;false&gt; </p> <p> And the boost version is 1.33.1. By the way, the OS version is redhat 5.6 . Linux rhel5 2.6.18-238.el5 <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/1" title="#1: Bugs: boost.build causes ftjam to segfault (closed: Wont Fix)">#1</a> SMP Sun Dec 19 14:24:47 EST 2010 i686 i686 i386 GNU/Linux The gcc version is 4.1.2 . g++ -v Using built-in specs. Target: i386-redhat-linux config option: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-<span class="underline">cxa_atexit --disable-libunwind-exceptions --enable-libgcj-multifile --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --disable-plugin --with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre --with-cpu=generic --host=i386-redhat-linux thread module: posix gcc version 4.1.2 20080704 (Red Hat 4.1.2-50) </span></p> <p> But the same codes can be compiled well, no compile errors in the other linux. Such as redhat4.3 and 6.0 How can I fix it? Thank you. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/6107 Trac 1.4.3 mtloveft@… Wed, 09 Nov 2011 04:21:04 GMT component changed; owner set; version deleted https://svn.boost.org/trac10/ticket/6107#comment:1 https://svn.boost.org/trac10/ticket/6107#comment:1 <ul> <li><strong>owner</strong> set to <span class="trac-author">Robert Ramey</span> </li> <li><strong>version</strong> <span class="trac-field-deleted">Boost 1.47.0</span> </li> <li><strong>component</strong> <span class="trac-field-old">None</span> → <span class="trac-field-new">serialization</span> </li> </ul> Ticket Robert Ramey Sat, 12 Nov 2011 20:49:52 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/6107#comment:2 https://svn.boost.org/trac10/ticket/6107#comment:2 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">wontfix</span> </li> </ul> <p> I'm going to assume that this is particular the the compiler version. Try upgrading to a more recent version of GCC. Since I don't have the the setup to reproduce this, I'll have to say I don't see what I can do about this. If you have a tested patch, I would be willing to look at it. Otherwise I'm going to have to close this ticket. Sorry I couldn't be more helpful. </p> <p> Robert Ramey </p> Ticket