[compiler-rt] [llvm] [ASan] Do not instrument catch block parameters on Windows (PR #159618)

David Justo via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 17 09:13:25 PDT 2025


================
@@ -0,0 +1,33 @@
+// RUN: %clangxx_asan %s -o %t
+// RUN: %run %t | FileCheck %s
+
+// This test tests that declaring a parameter in a catch-block does not produce a false positive
+// ASan error on Windows.
+
+// This code is based on the repro in https://github.com/google/sanitizers/issues/749
+#include <cstdio>
+#include <exception>
+
+void throwInFunction() { throw std::exception("test2"); }
+
+int main() {
+  // case 1: direct throw
+  try {
+    throw std::exception("test1");
+  } catch (const std::exception &ex) {
+    puts(ex.what());
+    // CHECK: test1
+  }
+
+  // case 2: throw in function
+  try {
+    throwInFunction();
+  } catch (const std::exception &ex) {
+    puts(ex.what());
+    // CHECK: test2
+  }
+
+  printf("Success!\n");
+  // CHECK: Success!
+  return 0;
+}
----------------
davidmrdavid wrote:

thanks, incorporated: https://github.com/llvm/llvm-project/pull/159618/commits/2f544df0a7d513915ebca22e4d84af792e3e0417

https://github.com/llvm/llvm-project/pull/159618


More information about the llvm-commits mailing list