Boost logo

Boost :

Subject: Re: [boost] [test] crash with the following test
From: Jürgen Hunold (juergen.hunold_at_[hidden])
Date: 2010-09-28 14:33:29


Hi Felipe,

On Tuesday, 28. September 2010 20:00:15 Felipe Magno de Almeida wrote:
> > Please provide more information. A backtrace is better, a compileable
> > test best. Some archive I can unpack and run "bjam" on, the very best
> > ;-))
>
> Attached a Jamroot and test.cpp that shows the problem.

Thanks.

> I'm using Windows XP Pro SP3 and msvc-9.0. But it is reproduceable
> with msvc-10.0express and msvc-8.0.

Not surprisingly, this works with gcc-4.4 on linux.

msvc-9.0 complains with

BOOST_ROOT\boost/test/impl/unit_test_main.ipp(175) : error C2491:
'boost::unit_test::unit_test_main' : definition of dllimport function not
allowed
BOOST_ROOT\boost/test/impl/unit_test_monitor.ipp(61) : warning C4273:
'boost::unit_test::unit_test_monitor_t::execute_and_translate' : inconsistent
dll linkage

and so fails to build the example for me.

The main mistake is that you link against the Unit-Test library and use the
"included" variant at the same time.

Either removing the dependency on the library and adding the include paths
with <use>:

project test
  : requirements
    <use>/boost//headers
  ;

alias test :
  [ run test1.cpp
  ] ;

or changing test1.cpp to #include the library header only:

//#include <boost/test/included/unit_test.hpp>
#include <boost/test/unit_test.hpp>

will fix this. Otherwise, you get _serious_ UB.

Yours,

Jürgen

-- 
* Dipl.-Math. Jürgen Hunold       ! Ingenieurgesellschaft für 
* voice: ++49 511 262926 57       ! Verkehrs- und Eisenbahnwesen mbH  
* fax  : ++49 511 262926 99       ! Lister Straße 15
* juergen.hunold_at_[hidden]        ! www.ivembh.de
* 
* Geschäftsführer:                ! Sitz des Unternehmens: Hannover
* Prof. Dr.-Ing. Thomas Siefer    ! Amtsgericht Hannover, HRB 56965
* PD Dr.-Ing. Alfons Radtke       !

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