Boost logo

Boost Users :

Subject: Re: [Boost-users] [Phoenix] boost::phoenix::erase crashes the app in VS2008
From: Paul Heil (paul.heil_at_[hidden])
Date: 2012-06-18 09:46:13


On Sat, Jun 16, 2012 at 7:43 PM, Steven Watanabe <watanabesj_at_[hidden]>wrote:

> 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 mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>

Thanks, that fixed the issue. Now that I see it, I wonder why that even
compiled!



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