Boost logo

Boost :

From: Oliver Kullmann (O.Kullmann_at_[hidden])
Date: 2004-12-06 03:41:41


On Mon, Dec 06, 2004 at 10:29:23AM +0300, Vladimir Prus wrote:
> 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.
>

Hi,

don't know what you mean here (I didn't reply to anything?!).
 
> > 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 {
> public:
> ............
> 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.
>

Good to hear; then the documentation is (fortunately) wrong (it actually has
problems at many places):

boost_1_32_0/doc/html/value_semantic.html

class value_semantic {
public:
  // construct/copy/destruct
  ~value_semantic();

> > 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: libstdc++.so.5, needed by
> > /usr/local/lib/gcc/i686-pc-linux-gnu/3.4.3/../../../libboost_program_options-gcc.so,
> > may conflict with libstdc++.so.6
> >
> > (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.
>

As I said, I did built Boost with g++ 3.4.3; so I think under certain circumstances
the build doesn't work. (By the way, the previous version of g++ on that system was
3.4.2.)

In any case, it seems that the Boost documentation does not contain at any place a
detailed description how to link, and that seems to be something worth adding.
 
> This example works for me, when g++ 3.3 is used for everything.
>
> > Reading symbols from /lib/ld-linux.so.2...done.
> > Loaded symbols for /lib/ld-linux.so.2
> > #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.
>

should be; as I said, I did built Boost with 3.4.3, and that we get a crash seems to indicate to
me, that at least in the documentation of Boost in general there should be paid more attention
to linking issues.

Oliver
 


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