Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2003-10-17 08:56:44


Vladimir Prus wrote:

> Hi,
> I've just updated my copy of boost-sandbox and start to get the following
> error from g++ 3.3:
   ^^^^^
That's a warning, not an error.

> /space/NM/boost-sandbox/boost/sequence_algo/container_algo.hpp: In function `
> typename boost::container_traits<Container>::const_iterator
> boost::find(const Container&, const T&) [with Container = std::vector<int,
> std::allocator<int> >, T = int]':
> .../../lib/lvk/program_analysis/dataflow.cpp:145: instantiated from here
> /space/NM/boost-sandbox/boost/sequence_algo/container_algo.hpp:150: warning:
> cannot
> pass objects of non-POD type `struct
> boost::contiguous_sequence_container_tag' through `...'; call will abort at
> runtime
>
> When I compile the container_algo.cpp test program it produces lots of
> similiar warnings, after which I get:
>
> bash-2.05b$ ./a.out
> Segmentation fault
>
> Seems like the warning is correct in predicting crash?

No, the function is never called.

> I suggest that instead of using "tag" types for determining the right function
> to call, the pointer to "tag" is used. I.e. for one fragment one would get:
>
> template< typename C, typename T >
> inline typename container_traits<C>::iterator
> find_impl( C& c, const T& value, associative_container_tag* ) ...
>
> template< typename C, typename T >
> inline typename container_traits<C>::iterator
> find_impl( C& c, const T& value, ... ) .....

I don't know if that change is applicable in this case, but in general
it is not, since the type to be passed may be a reference type.

> When I make the change, the test passes. The patch attached. It also fixes
> several missing typenames, but the problem is that some of the lines are now
> way longer than 80 symbols.
>
> - Volodya

-Dave


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