Ticket #13481: crash.cpp

File crash.cpp, 715 bytes (added by Joakim Tosteberg <joakim.tosteberg@…>, 5 years ago)
Line 
1//
2// Copyright (c) 2015 Zenterio AB
3//
4#include <stdio.h>
5#include <boost/function.hpp>
6#include <boost/bind.hpp>
7
8#define DO_CRASH
9
10#include <string>
11
12class Test
13{
14public:
15 Test(boost::function<void()> a_Function) : m_Function(a_Function)
16 {
17 // Empty
18 }
19
20 void F()
21 {
22 m_Function();
23 }
24
25private:
26 boost::function<void()> m_Function;
27};
28
29void Fn(int val)
30{
31 printf("val=%d\r\n", val);
32}
33
34void DoTest()
35{
36 printf("1\r\n");
37 boost::function<void()> f = boost::bind(Fn, 100);
38 Test test(f);
39#ifndef DO_CRASH
40 printf("2\r\n"); // printf of life!
41#endif
42 test.F();
43 printf("3\r\n");
44}
45
46int main(int argc, char** argv)
47{
48 DoTest();
49 return 0;
50}