Boost logo

Boost :

From: Vladimir Prus (ghost_at_[hidden])
Date: 2004-12-06 02:29:23

Hi Oliver,

> Hello,
> I would like to report 3 issues with the
> program_options library, 2 of which seem
> critical to me:

First of all, please don't ask questions by replying to unrelated messages,
this causes inconvenience for reading.

> 1) The class boost::program_options::value_semantic
> is a polymorphic class (has virtual functions), but
> has a non-virtual destructor.

Excuse me, but here's the code that *I* see:

    class BOOST_PROGRAM_OPTIONS_DECL value_semantic {
        virtual ~value_semantic() {}

Now, you must be either looking at a different class, or at a pre-release
version of the library (though I think dtor was virtual all the time), or
overlooked this definition.

> Perhaps the following crash, when using program_options in a trivial
> way, is already caused by this error.
> 2) Consider the following program "Error_program_options"
> #include <boost/program_options.hpp>
> int main() {
> boost::program_options::options_description d("Options");
> }
> I compiled it (using g++, version 3.4.3) via
>> g++ -g Error_program_options.cpp -lboost_program_options-gcc
> I got the warning
> /usr/bin/ld: warning:, needed by
> /usr/local/lib/gcc/i686-pc-linux-gnu/3.4.3/../../../,
> may conflict with
> (see point 3), but this doesn't seem to be of importance here.

Actually, this means that you've built program_options with g++ 3.3 and
compile you program with g++ 3.4. The C++ standard library is not
compatible in those versions, so anything can happen, including a crash.

This example works for me, when g++ 3.3 is used for everything.

> Reading symbols from /lib/
> Loaded symbols for /lib/
> #0 0x0804923a in boost::detail::sp_counted_base::release()
> #(this=0x838dffff)
> at shared_count.hpp:142
> 142 long new_use_count = --use_count_;
> Thus it could be, that the problem reported unter 1) causes the crash here
> (on the other hand, actually for the above trivial program no object of
> type value_semantic seems to be created, but unfortunately I don't have
> the time to investigate this further).

It seems likely that mixing code compiled with 3.3 and 3.4 is the reason for
the crash.

- Volodya

Boost list run by bdawes at, gregod at, cpdaniel at, john at