From 5f15c8f77ee4333bc514c9093036a279d4a4dfd6 Mon Sep 17 00:00:00 2001 From: Matt Borland Date: Mon, 8 Sep 2025 13:33:51 +0200 Subject: [PATCH] Add div by 0 check --- include/boost/math/special_functions/hypot.hpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/boost/math/special_functions/hypot.hpp b/include/boost/math/special_functions/hypot.hpp index c06dfa4c0..6623d414b 100644 --- a/include/boost/math/special_functions/hypot.hpp +++ b/include/boost/math/special_functions/hypot.hpp @@ -81,6 +81,12 @@ BOOST_MATH_GPU_ENABLED T hypot_impl(T x, T y, T z, const Policy& pol) #endif const T a {(max)((max)(x, y), z)}; + + if (a == T(0)) + { + return a; + } + const T x_div_a {x / a}; const T y_div_a {y / a}; const T z_div_a {z / a};