Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / lsan / TestCases / lsan_crash.cpp
blob14f9d872b2602d4e0308cbb4fc8118f88e03ef80
1 // RUN: %clangxx_lsan -O2 %s --std=c++14 -o %t && %run %t
3 #include <atomic>
4 #include <memory>
5 #include <sanitizer/lsan_interface.h>
6 #include <thread>
7 #include <vector>
9 std::atomic<bool> done;
11 void foo() {
12 std::unique_ptr<char[]> mem;
14 while (!done)
15 mem.reset(new char[1000000]);
18 int main() {
19 std::vector<std::thread> threads;
20 for (int i = 0; i < 10; ++i)
21 threads.emplace_back(foo);
23 for (int i = 0; i < 100; ++i)
24 __lsan_do_recoverable_leak_check();
26 done = true;
27 for (auto &t : threads)
28 t.join();
30 return 0;