[Boost-bugs] [Boost C++ Libraries] #7356: program crashed when using phoenix::switch_, case<> with STL::for_each, using std::vector<int> as the container

Subject: [Boost-bugs] [Boost C++ Libraries] #7356: program crashed when using phoenix::switch_, case<> with STL::for_each, using std::vector<int> as the container
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2012-09-10 13:34:10


#7356: program crashed when using phoenix::switch_,case<> with STL::for_each,
using std::vector<int> as the container
-----------------------------+----------------------------------------------
 Reporter: wqgg123@… | Type: Bugs
   Status: new | Milestone: To Be Determined
Component: None | Version: Boost 1.51.0
 Severity: Problem | Keywords: phoenix::switch_
-----------------------------+----------------------------------------------
 Problem: the program is listed as bellow, complied with mingw32-gcc-4.6.2,
 enabling std++0x. The program is OK when running in debug model, but
 crashed in release mode. The error code is -1073741819.


 #include <iostream>
 #include <vector>
 #include <algorithm>
 #include <boost/phoenix.hpp>

 using namespace std;
 using namespace boost;
 using phoenix::placeholders::arg1;

 int main()
 {
     vector<int> vec = {1, 2, 3, 4, 5, 6, 7, 8, 9};

     for_each(vec.begin(), vec.end(),
              switch_(arg1)
              [
                 phoenix::case_<1>(cout << phoenix::val("One") << '\n'),
                 phoenix::case_<2>(cout << phoenix::val("Two") << '\n'),
                 phoenix::default_(cout << phoenix::val("other value") <<
 '\n')
              ]);
     return 0;
 }

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/7356>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:10 UTC