Boost logo

Boost Users :

Subject: Re: [Boost-users] [Phoenix] boost::phoenix::erase crashes the app in VS2008
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2012-06-16 20:43:44


AMDG

On 06/14/2012 11:17 AM, Paul Heil wrote:
> I have a Visual Studio 2008 C++03 application where I'm using
> boost::phoenix::erase (v1.49.0) on a std::list<int> container that does not
> contain the element I want to erase.
>
> This example is demonstrates the issue:
>
> int main()
> {
> namespace bp = boost::phoenix;
> namespace bpa = boost::phoenix::arg_names;
>
> std::list< int > a;
>
> // works as expected (does nothing)
> a.erase( a.end(), a.end() );
>
> // fails a debug assertion "list erase iterator outside range"
> // Microsoft Visual Studio 9.0\VC\include\list\list : 790
> bp::erase( bp::ref( a ), a.end() )();
>
> return 0;
> }
>
> In release mode, this de-references an uninitialized pointer and the
> application crashes. Am I using boost::phoenix::erase correctly?
>

Your phoenix code only passes one iter.
a.erase(a.end()) is illegal.

To get the equivent of your non-phoenix
code, you need
bp::erase(bp::ref( a ), a.end(), a.end());

In Christ,
Steven Watanabe


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net