Skip to content

Commit bff409d

Browse files
committed
add basic unit test: catches exception 'inline' and in another frame
1 parent ece2a2b commit bff409d

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// RUN: %clangxx_asan %s -o %t
2+
// RUN: %run %t | FileCheck %s
3+
4+
// This test tests that declaring a parameter in a catch-block does not produce a false positive
5+
// ASan error on Windows.
6+
7+
// This code is based on the repro in https://github.com/google/sanitizers/issues/749
8+
#include <cstdio>
9+
#include <exception>
10+
11+
void throwInFunction(){
12+
throw std::exception("test2");
13+
}
14+
15+
int main()
16+
{
17+
// case 1: direct throw
18+
try {
19+
throw std::exception("test1");
20+
} catch (const std::exception& ex){
21+
puts(ex.what());
22+
// CHECK: test1
23+
}
24+
25+
// case 2: throw in function
26+
try {
27+
throwInFunction();
28+
} catch (const std::exception& ex){
29+
puts(ex.what());
30+
// CHECK: test2
31+
}
32+
33+
printf("Success!\n");
34+
// CHECK: Success!
35+
return 0;
36+
}

0 commit comments

Comments
 (0)