$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
Subject: Re: [boost] [Serialization] can BOOST_ASSERT have method calls?
From: Robert Ramey (ramey_at_[hidden])
Date: 2011-01-18 11:29:56
Patrick Horgan wrote:
> I noticed in serializations basic_iarchive that when you're not
> building for debug the next line here (317 in basic_iarchive.cpp) has a 
> warning
> for unused variable new_cid.  The BOOST_ASSERT is instantiated as
> ((void)0) so new_cid really isn't used.  Could the register_type call
> be moved into the assert?
>
>        class_id_type new_cid =
> register_type(bpis_ptr->get_basic_serializer());
>         int i = cid;
>         cobject_id_vector[i].bpis_ptr = bpis_ptr;
>         BOOST_ASSERT(new_cid == cid);
>
> Something like:
>
>         BOOST_ASSERT(register_type(bpis_ptr->get_basic_serializer())
> == cid);
>
> Then the new_cid variable wouldn't be needed and the call to
> register_type would disappear with the BOOST_ASSERT if you aren't
> building for debug.
which would break the program.
> Or, does the call to register_type have an
> important side effect that is required?
It does. It must be called.  What is optional is checking the return type.
I do this during debug to verify code.  I suppose the motiviation here
is to eliminate a spurious warning.  This could be done but doing
a little #ifdef hack.  If you want to do this,  make a patch, test it
and submit it through the track system.
Robert Ramey
>
> Patrick
> _______________________________________________
> Unsubscribe & other changes:
> http://listarchives.boost.org/mailman/listinfo.cgi/boost