From b4b4a5a8451e9cb8f8a95e0e357325dfdbd3480f Mon Sep 17 00:00:00 2001
From: Maximilian Reininghaus <maximilian.reininghaus@tu-dortmund.de>
Date: Wed, 26 Dec 2018 21:05:37 +0100
Subject: [PATCH] throw exception on NaN generation in Sibyll decay function

---
 Processes/Sibyll/Decay.h | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/Processes/Sibyll/Decay.h b/Processes/Sibyll/Decay.h
index 93516c141..4bf06c3ef 100644
--- a/Processes/Sibyll/Decay.h
+++ b/Processes/Sibyll/Decay.h
@@ -10,6 +10,8 @@
 
 #include <corsika/particles/ParticleProperties.h>
 
+#include <fenv.h>
+
 namespace corsika::process {
 
   namespace sibyll {
@@ -145,6 +147,9 @@ namespace corsika::process {
       void DoDecay(Particle& p, Stack& s) const {
         using corsika::geometry::Point;
         using namespace corsika::units::si;
+
+	feenableexcept(FE_INVALID);
+
         fCount++;
         SibStack ss;
         ss.Clear();
@@ -188,6 +193,8 @@ namespace corsika::process {
         }
         // empty sibyll stack
         ss.Clear();
+
+	fedisableexcept(FE_INVALID);
       }
     };
   } // namespace sibyll
-- 
GitLab