aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/test/sigsegv/CMakeLists.txt
diff options
context:
space:
mode:
Diffstat (limited to 'test/sigsegv/CMakeLists.txt')
-rw-r--r--test/sigsegv/CMakeLists.txt11
1 files changed, 11 insertions, 0 deletions
diff --git a/test/sigsegv/CMakeLists.txt b/test/sigsegv/CMakeLists.txt
new file mode 100644
index 0000000..b92147d
--- /dev/null
+++ b/test/sigsegv/CMakeLists.txt
@@ -0,0 +1,11 @@
+# Hopefully putting the NULL reference to a separate library should force the
+# sigsegv binary to crash. If I put it in main.c, surprisingly, Clang (with
+# -O2) produces a binary that doesn't crash: https://godbolt.org/z/joeqEEs3Y.
+# To force it to crash, the -fno-delete-null-pointer-checks flag is required:
+# https://godbolt.org/z/o3xEoeG3z. This is a bit hacky though; putting the
+# reference in a separate library should also do the trick.
+
+add_library(null lib.c)
+
+add_executable(sigsegv main.c)
+target_link_libraries(sigsegv PRIVATE null)