Opened 10 years ago
Closed 6 years ago
#7356 closed Bugs (fixed)
program crashed when using phoenix::switch_,case<> with STL::for_each, using std::vector<int> as the container
Reported by: | Owned by: | Thomas Heller | |
---|---|---|---|
Milestone: | To Be Determined | Component: | phoenix |
Version: | Boost 1.51.0 | Severity: | Problem |
Keywords: | phoenix::switch_ | Cc: |
Description
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;
}
Change History (3)
comment:1 by , 10 years ago
Component: | None → phoenix |
---|---|
Owner: | set to |
comment:2 by , 10 years ago
comment:3 by , 6 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
1.52 fixes this issue. http://melpon.org/wandbox/permlink/iwweR1lSD3MPLEQD
Note: 1.51 crashes. http://melpon.org/wandbox/permlink/FaOhgX1NXUbC2o4H
See also: http://stackoverflow.com/questions/14063880/why-does-this-proto-phoenix-toy-example-crash