1 #include <string>
2 #include <map>
3
4 #define intint_map std::multimap<int, int>
5 #define strint_map std::multimap<std::string, int>
6 #define intstr_map std::multimap<int, std::string>
7 #define strstr_map std::multimap<std::string, std::string>
8
9 int g_the_foo = 0;
10
thefoo_rw(int arg=1)11 int thefoo_rw(int arg = 1)
12 {
13 if (arg < 0)
14 arg = 0;
15 if (!arg)
16 arg = 1;
17 g_the_foo += arg;
18 return g_the_foo;
19 }
20
main()21 int main()
22 {
23 char buffer[sizeof(intint_map)] = {0};
24 intint_map &corrupt_map = *(intint_map *)buffer;
25
26 intint_map ii; // Set break point at this line.
27
28 ii.emplace(0,0); // Set break point at this line.
29 ii.emplace(1,1);
30 thefoo_rw(1); // Set break point at this line.
31 ii.emplace(2,0);
32 ii.emplace(3,1);
33 thefoo_rw(1); // Set break point at this line.
34 ii.emplace(4,0);
35 ii.emplace(5,1);
36 ii.emplace(6,0);
37 ii.emplace(7,1);
38 thefoo_rw(1); // Set break point at this line.
39 ii.emplace(85,1234567);
40
41 ii.clear();
42
43 strint_map si;
44 thefoo_rw(1); // Set break point at this line.
45
46 si.emplace("zero",0);
47 thefoo_rw(1); // Set break point at this line.
48 si.emplace("one",1);
49 si.emplace("two",2);
50 si.emplace("three",3);
51 thefoo_rw(1); // Set break point at this line.
52 si.emplace("four",4);
53
54 si.clear();
55 thefoo_rw(1); // Set break point at this line.
56
57 intstr_map is;
58 thefoo_rw(1); // Set break point at this line.
59 is.emplace(85,"goofy");
60 is.emplace(1,"is");
61 is.emplace(2,"smart");
62 is.emplace(3,"!!!");
63 thefoo_rw(1); // Set break point at this line.
64
65 is.clear();
66 thefoo_rw(1); // Set break point at this line.
67
68 strstr_map ss;
69 thefoo_rw(1); // Set break point at this line.
70
71 ss.emplace("ciao","hello");
72 ss.emplace("casa","house");
73 ss.emplace("gatto","cat");
74 thefoo_rw(1); // Set break point at this line.
75 ss.emplace("a Mac..","..is always a Mac!");
76
77 ss.clear();
78 thefoo_rw(1); // Set break point at this line.
79 return 0;
80 }
81