1 | #include <string> |
2 | #include <unordered_map> |
3 | #include <unordered_set> |
4 | |
5 | int g_the_foo = 0; |
6 | |
7 | int thefoo_rw(int arg = 1) { |
8 | if (arg < 0) |
9 | arg = 0; |
10 | if (!arg) |
11 | arg = 1; |
12 | g_the_foo += arg; |
13 | return g_the_foo; |
14 | } |
15 | |
16 | int main() { |
17 | |
18 | char buffer[sizeof(std::unordered_map<int, std::string>)] = {0}; |
19 | std::unordered_map<int, std::string> &corrupt_map = *(std::unordered_map<int, std::string> *)buffer; |
20 | |
21 | std::unordered_map<int, std::string> map; // Set break point at this line. |
22 | map.emplace(args: 1, args: "hello" ); |
23 | map.emplace(args: 2, args: "world" ); |
24 | map.emplace(args: 3, args: "this" ); |
25 | map.emplace(args: 4, args: "is" ); |
26 | map.emplace(args: 5, args: "me" ); |
27 | thefoo_rw(); // Set break point at this line. |
28 | |
29 | std::unordered_multimap<int, std::string> mmap; |
30 | mmap.emplace(args: 1, args: "hello" ); |
31 | mmap.emplace(args: 2, args: "hello" ); |
32 | mmap.emplace(args: 2, args: "world" ); |
33 | mmap.emplace(args: 3, args: "this" ); |
34 | mmap.emplace(args: 3, args: "this" ); |
35 | mmap.emplace(args: 3, args: "this" ); |
36 | thefoo_rw(); // Set break point at this line. |
37 | |
38 | std::unordered_set<int> iset; |
39 | iset.emplace(args: 1); |
40 | iset.emplace(args: 2); |
41 | iset.emplace(args: 3); |
42 | iset.emplace(args: 4); |
43 | iset.emplace(args: 5); |
44 | thefoo_rw(); // Set break point at this line. |
45 | |
46 | std::unordered_set<std::string> sset; |
47 | sset.emplace(args: "hello" ); |
48 | sset.emplace(args: "world" ); |
49 | sset.emplace(args: "this" ); |
50 | sset.emplace(args: "is" ); |
51 | sset.emplace(args: "me" ); |
52 | thefoo_rw(); // Set break point at this line. |
53 | |
54 | std::unordered_multiset<int> imset; |
55 | imset.emplace(args: 1); |
56 | imset.emplace(args: 2); |
57 | imset.emplace(args: 2); |
58 | imset.emplace(args: 3); |
59 | imset.emplace(args: 3); |
60 | imset.emplace(args: 3); |
61 | thefoo_rw(); // Set break point at this line. |
62 | |
63 | std::unordered_multiset<std::string> smset; |
64 | smset.emplace(args: "hello" ); |
65 | smset.emplace(args: "world" ); |
66 | smset.emplace(args: "world" ); |
67 | smset.emplace(args: "is" ); |
68 | smset.emplace(args: "is" ); |
69 | thefoo_rw(); // Set break point at this line. |
70 | |
71 | return 0; |
72 | } |
73 | |