[serialization] seems like a bug in MSVS 7.1 is preventing use of the library

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[serialization] seems like a bug in MSVS 7.1 is preventing use of the library

Scott-94
Hello,

I've been trying for days to get a simple serialization example to work in
our main project.  I finally started taking snippets of code from the
regular project into a sample project to post the code here.  However, all
the code in my sample project always compiles and runs.  It's practically
identical to our main project.

At this point, I'm pretty sure I've stumbled unto a bug in the compiler.  I
even found a web page that seems to have the same problem I have:

http://aspn.activestate.com/ASPN/Mail/Message/boost/2768351


Here's a small sample of the problem:

struct Node
{
        unsigned int handle;

        template <typename Archive>
        void save(Archive& ar, const unsigned int version) const
        {
                ar << handle;
        }

        template <typename Archive>
        void load(Archive& ar, const unsigned int version)
        {
                ar >> handle;
        }
        BOOST_SERIALIZATION_SPLIT_MEMBER()
}

In a nutshell, I have a std::map<unsigned int, Node> that I'm trying to
serialize.  The code to save compiles fine.  But the load() method fails on
compile with the STATIC_ASSERTION_FAILURE.  If I comment out the ar >>
handle;, it compiles fine.  If I then uncomment ar >> handle; (after a good
compile), it STILL COMPILES FINE.  If I do a clean/rebuild of the project,
it then fails with the STATIC_ASSERTION_FAILURE!

I went into the iserializer.hpp:577 header of boost and found the offending
line:


    // if this assertion trips. It means we're trying to load a
    // const object with a compiler that doesn't have correct
    // funtion template ordering.  On other compilers, this is
    // handled below.
    BOOST_STATIC_ASSERT(! boost::is_const<T>::value);


Based on the comment above, it seems MSVC 7.1 is having problems with
correct function template ordering?  On a whim, I commented out the
BOOST_STATIC_ASSERT and now I see this compile error:

..\API\inc\boost\archive\basic_text_iprimitive.hpp(80) : error C2679: binary
'>>' : no operator found which takes a right-hand operand of type 'const
unsigned int' (or there is no acceptable conversion)
        ..\API\inc\boost\archive\text_iarchive.hpp(45) : see reference to
function template instantiation 'void
boost::archive::basic_text_iprimitive<IStream>::load<T>(T &)' being compiled
        with
        [
            IStream=std::istream,
            T=const unsigned int
        ]


My question is - how can I solve this so I can use serialization?  The link
above seems to indicate boost 1.32 works for Microsoft Visual Studio 7.1.
Are there any other possible solutions that don't involve rolling back to an
earlier boost version?

Thanks for any help,
Scott

_______________________________________________
Boost-users mailing list
[hidden email]
http://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: [serialization] seems like a bug in MSVS 7.1 ispreventing use of the library

Robert Ramey
Your sample doesn't reveal enough of the code to indicate the problem.
The code below is OK.

The problem is somewhere above (keep clicking the error messsages back
up the stack, you've got something like:

load(Archive &ar, const X &x, const unsigned int version){
    ar >> x;
}

The X could also be something like

map<const int> or some such.

Good Luck
Robert Ramey

cheesy4poofs wrote:

> Hello,
>
> I've been trying for days to get a simple serialization example to
> work in our main project.  I finally started taking snippets of code
> from the regular project into a sample project to post the code here.
> However, all the code in my sample project always compiles and runs.
> It's practically identical to our main project.
>
> At this point, I'm pretty sure I've stumbled unto a bug in the
> compiler.  I even found a web page that seems to have the same
> problem I have:
>
> http://aspn.activestate.com/ASPN/Mail/Message/boost/2768351
>
>
> Here's a small sample of the problem:
>
> struct Node
> {
> unsigned int handle;
>
> template <typename Archive>
> void save(Archive& ar, const unsigned int version) const
> {
> ar << handle;
> }
>
> template <typename Archive>
> void load(Archive& ar, const unsigned int version)
> {
> ar >> handle;
> }
> BOOST_SERIALIZATION_SPLIT_MEMBER()
> }
>
> In a nutshell, I have a std::map<unsigned int, Node> that I'm trying
> to serialize.  The code to save compiles fine.  But the load() method
> fails on compile with the STATIC_ASSERTION_FAILURE.  If I comment out
> the ar >> handle;, it compiles fine.  If I then uncomment ar >>
> handle; (after a good compile), it STILL COMPILES FINE.  If I do a
> clean/rebuild of the project, it then fails with the
> STATIC_ASSERTION_FAILURE!
>
> I went into the iserializer.hpp:577 header of boost and found the
> offending line:
>
>
>    // if this assertion trips. It means we're trying to load a
>    // const object with a compiler that doesn't have correct
>    // funtion template ordering.  On other compilers, this is
>    // handled below.
>    BOOST_STATIC_ASSERT(! boost::is_const<T>::value);
>
>
> Based on the comment above, it seems MSVC 7.1 is having problems with
> correct function template ordering?  On a whim, I commented out the
> BOOST_STATIC_ASSERT and now I see this compile error:
>
> ..\API\inc\boost\archive\basic_text_iprimitive.hpp(80) : error C2679:
> binary '>>' : no operator found which takes a right-hand operand of
> type 'const unsigned int' (or there is no acceptable conversion)
>        ..\API\inc\boost\archive\text_iarchive.hpp(45) : see reference
> to function template instantiation 'void
> boost::archive::basic_text_iprimitive<IStream>::load<T>(T &)' being
>        compiled with
>        [
>            IStream=std::istream,
>            T=const unsigned int
>        ]
>
>
> My question is - how can I solve this so I can use serialization?
> The link above seems to indicate boost 1.32 works for Microsoft
> Visual Studio 7.1. Are there any other possible solutions that don't
> involve rolling back to an earlier boost version?
>
> Thanks for any help,
> Scott



_______________________________________________
Boost-users mailing list
[hidden email]
http://lists.boost.org/mailman/listinfo.cgi/boost-users