[Phoenix] boost::phoenix::erase crashes the app in VS2008

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? Thanks

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

On Sat, Jun 16, 2012 at 7:43 PM, Steven Watanabe
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@lists.boost.org 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!
participants (2)
-
Paul Heil
-
Steven Watanabe