浏览代码

Add extra exceptions for arithmetic and types operations (#1001)

* This PR allows for extra exceptions in the debug mode (GCC/LLVM) on Linux based OSes - it does not work on the other operating systems.
Relevant documentation: https://linux.die.net/man/3/feenableexcept
Kacper Pluta 5 年之前
父节点
当前提交
f029832904
共有 1 个文件被更改,包括 17 次插入1 次删除
  1. 17 1
      tests/main.cpp

+ 17 - 1
tests/main.cpp

@@ -3,4 +3,20 @@
 ////////////////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////////////////
 
 
 #define CATCH_CONFIG_MAIN
 #define CATCH_CONFIG_MAIN
-#include <catch2/catch.hpp>
+#include <catch2/catch.hpp>
+ 
+#ifndef NDEBUG
+#ifdef __linux__
+#include <fenv.h>
+#endif
+#endif
+
+#ifndef NDEBUG
+#ifdef __linux__
+void beforeMain (void) __attribute__((constructor));
+void beforeMain (void)
+{
+    feenableexcept(FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW);
+}
+#endif
+#endif