[archive] -- error compiling CVS Head

I'm getting the compile errors below when compiling the lastest code from CVS on Debian with gcc 4.1.2 # g++ --version g++ (GCC) 4.1.2 20060920 (prerelease) (Debian 4.1.1-14) This happened also with g++-4.0 (GCC) 4.0.4 20060630 (prerelease) (Debian 4.0.3-5) I'm not sure if it is a compiler problem, or a code problem. It all compiled the last time I tried a few weeks ago. I noticed recent activity on dynamically_initialized.hpp where instance is decared. I tried with the current revision of the file, and one back. Both produce the same error. ./boost/archive/detail/iserializer.hpp: In static member function 'static const boost::archive::detail::pointer_iserializer<Archive, T>& boost::archive::detail::pointer_iserializer<Archive, T>::get_instance()': ./boost/archive/detail/iserializer.hpp:329: error: 'instance' was not declared in this scope ./boost/archive/detail/oserializer.hpp: In static member function 'static const boost::archive::detail::pointer_oserializer<Archive, T>& boost::archive::detail::pointer_oserializer<Archive, T>::get_instance()': ./boost/archive/detail/oserializer.hpp:230: error: 'instance' was not declared in this scope Brian

Brian Schrom wrote:
I'm getting the compile errors below when compiling the lastest code from CVS on Debian with gcc 4.1.2
# g++ --version g++ (GCC) 4.1.2 20060920 (prerelease) (Debian 4.1.1-14)
This happened also with g++-4.0 (GCC) 4.0.4 20060630 (prerelease) (Debian 4.0.3-5)
I'm not sure if it is a compiler problem, or a code problem. It all compiled the last time I tried a few weeks ago. I noticed recent activity on dynamically_initialized.hpp where instance is decared. I tried with the current revision of the file, and one back. Both produce the same error.
./boost/archive/detail/iserializer.hpp: In static member function 'static const boost::archive::detail::pointer_iserializer<Archive, T>& boost::archive::detail::pointer_iserializer<Archive, T>::get_instance()': ./boost/archive/detail/iserializer.hpp:329: error: 'instance' was not declared in this scope ./boost/archive/detail/oserializer.hpp: In static member function 'static const boost::archive::detail::pointer_oserializer<Archive, T>& boost::archive::detail::pointer_oserializer<Archive, T>::get_instance()': ./boost/archive/detail/oserializer.hpp:230: error: 'instance' was not declared in this scope
Looks as if 'instance' needs to be qualified by 'this->' since it comes from a dependent base class. Regards, Stefan -- ...ich hab' noch einen Koffer in Berlin...

To address a complaint from the Commeau compiler I changed to return dynamically_initialized<pointer_iserializer<Archive,T> >::instance; I haven't checked this in yet. Try it in your situation to see if that's the right fix. "this->" cannot be used as this is a static function w/o a "this" pointer. Robert Ramey Brian Schrom wrote:
I'm getting the compile errors below when compiling the lastest code from CVS on Debian with gcc 4.1.2
# g++ --version g++ (GCC) 4.1.2 20060920 (prerelease) (Debian 4.1.1-14)
This happened also with g++-4.0 (GCC) 4.0.4 20060630 (prerelease) (Debian 4.0.3-5)
I'm not sure if it is a compiler problem, or a code problem. It all compiled the last time I tried a few weeks ago. I noticed recent activity on dynamically_initialized.hpp where instance is decared. I tried with the current revision of the file, and one back. Both produce the same error.
./boost/archive/detail/iserializer.hpp: In static member function 'static const boost::archive::detail::pointer_iserializer<Archive, T>& boost::archive::detail::pointer_iserializer<Archive, T>::get_instance()': ./boost/archive/detail/iserializer.hpp:329: error: 'instance' was not declared in this scope ./boost/archive/detail/oserializer.hpp: In static member function 'static const boost::archive::detail::pointer_oserializer<Archive, T>& boost::archive::detail::pointer_oserializer<Archive, T>::get_instance()': ./boost/archive/detail/oserializer.hpp:230: error: 'instance' was not declared in this scope
Brian _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

I put that line in iserializer and oserializer and that fixed that error. There are a few other warning messages if you care to know about them: ./boost/archive/polymorphic_iarchive.hpp:60: warning: 'class boost::archive::polymorphic_iarchive' has virtual functions but non-virtual destructor ./boost/archive/basic_binary_oprimitive.hpp: In member function 'void boost::archive::basic_binary_oprimitive<Archive, Elem, Tr>::save(bool) [with Archive = boost::archive::binary_woarchive, Elem = wchar_t, Tr = std::char_traits<wchar_t>]': libs/serialization/src/binary_woarchive.cpp:28: instantiated from here ./boost/archive/basic_binary_oprimitive.hpp:90: warning: unused variable 'i and similar Thanks for your help and quick response. Brian On Friday 29 September 2006 15:55, Robert Ramey wrote:
To address a complaint from the Commeau compiler I changed to
return dynamically_initialized<pointer_iserializer<Archive,T> >::instance;
I haven't checked this in yet. Try it in your situation to see if that's the
right fix.
"this->" cannot be used as this is a static function w/o a "this" pointer.
Robert Ramey

This is explained in the code in the cited place. it turns out that for particular reasons, polymophic archives can't be destroyed through the base class pointer. For this reason, the destructor is marked "protected" Robert Ramey Brian Schrom wrote:
I put that line in iserializer and oserializer and that fixed that error.
There are a few other warning messages if you care to know about them:
./boost/archive/polymorphic_iarchive.hpp:60: warning: 'class boost::archive::polymorphic_iarchive' has virtual functions but non-virtual destructor

Brian Schrom wrote:
There are a few other warning messages if you care to know about them:
./boost/archive/polymorphic_iarchive.hpp:60: warning: 'class boost::archive::polymorphic_iarchive' has virtual functions but non-virtual destructor
At 9:04 PM -0700 9/29/06, Robert Ramey wrote:
This is explained in the code in the cited place. it turns out that for particular reasons, polymophic archives can't be destroyed through the base class pointer. For this reason, the destructor is marked "protected"
The explanation in that comment is: ... there is no way to forward to the "true" destructor. I would have thought that simply making the polymorphic_[i,o]archive destructors virtual (as was discussed a few weeks ago when I brought up the problem of destructor slicing for these classes) would solve this problem. What am I overlooking?

Kim Barrett wrote:
There are a few other warning messages if you care to know about
Brian Schrom wrote: them:
./boost/archive/polymorphic_iarchive.hpp:60: warning: 'class boost::archive::polymorphic_iarchive' has virtual functions but non-virtual destructor
At 9:04 PM -0700 9/29/06, Robert Ramey wrote:
This is explained in the code in the cited place. it turns out that for particular reasons, polymophic archives can't be destroyed through the base class pointer. For this reason, the destructor is marked "protected"
The explanation in that comment is:
... there is no way to forward to the "true" destructor.
I would have thought that simply making the polymorphic_[i,o]archive destructors virtual (as was discussed a few weeks ago when I brought up the problem of destructor slicing for these classes) would solve this problem. What am I overlooking?
Well, that's what I thought. Then I looked into it. When I tried it I got problems due the the fact that the most derived class is derived from multiple bases. see http://www.boost.org/libs/serialization/doc/class_diagram.html It's easy to see by making the change to "virtual" with your original example. I didn't see an easy way to fix it and I didn't see it as a big problem so I just punted. Robert Ramey
participants (4)
-
Brian Schrom
-
Kim Barrett
-
Robert Ramey
-
Stefan Seefeld