Boost logo

Boost :

From: BRIDGES Dick (Dick.Bridges_at_[hidden])
Date: 2005-08-24 13:16:10


When compiling the examples (statechart library downloaded from sf 18
Aug),
I get the following warnings:

<warnings format=edited>
/usr/local/boost_1_33_0/boost/statechart/detail/state_base.hpp:
In instantiation of
`boost::statechart::detail::state_base<std::allocator<void>,
boost::statechart::detail::rtti_policy>':
/usr/local/boost_1_33_0/boost/statechart/state_machine.hpp:443:
instantiated from
`boost::statechart::state_machine<Machine, Greeting,
std::allocator<void>,
boost::statechart::null_exception_translator>'
../main.cpp:12: instantiated from here
/usr/local/boost_1_33_0/boost/statechart/detail/state_base.hpp:74:
warning: `class
boost::statechart::detail::state_base<std::allocator<void>,
boost::statechart::detail::rtti_policy>' has virtual functions but
non-virtual destructor

[snip]

/usr/local/boost_1_33_0/boost/statechart/simple_state.hpp:189:
instantiated from
`boost::statechart::simple_state<Greeting, Machine,
boost::mpl::list<mpl_::na,
mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na,
mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na,mpl_::na, mpl_::na,
mpl_::na,
mpl_::na, mpl_::na, mpl_::na, mpl_::na>, has_no_history>'
../main.cpp:14: instantiated from here
/usr/local/boost_1_33_0/boost/statechart/detail/leaf_state.hpp:27:
warning: `class
boost::statechart::detail::leaf_state<std::allocator<void>,
boost::statechart::detail::rtti_policy>' has virtual functions but
non-virtual destructor
</warnings>

I changed ~simple_State() and ~state_base() to virtual and the warnings
disappeared. However, ~state_base() contains the following annotation:

// This destructor is not virtual for performance reasons. The library
// ensures that a state object is never deleted through a state_base
// pointer but only through a pointer to the most-derived type.
~state_base() {}

As a quick, not-definitive check, I built PingPong* with both the
virtual
and non-virtual dtorS using gcc 3.4.2 on an old i386-redhat-linux
machine.
The results appear to be the reverse of what I would expect, but I
checked
to verify that I have the correct result/config correspendence.

..................non-virtual.....virtual
PingPongSingle.... 4.08 ..... 3.71
PingPongMulti1.... 6.01997 ..... 5.85999
PingPongMulti2.... 19.53 ..... 19.55

Reminds me of the old joke: "I see fine. I just don't understand what
I'm looking at." Two questions: 1) will making the dtorS virtual lead
to adverse consequences I simply haven't encountered yet; and 2) can
someone help me understand what I did wrong in setting up this test?

<extra_credit ot=true my_understanding=faulty>
With a well-developed pipelined architecture and a reasonably rich set
of addressing operations, shouldn't there be little or no difference
between direct and indirect access times - given that the bookeeping
normally associated with virtual classes has already been paid for?
</extra_credit>

Thanks to any/all for help with this.

Regards,
Dick Bridges

"Multithreading is just one damn thing after, before, or simultaneous
with another." Scott Meyers and Andrei Alexandrescu


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