[PATCH][testsuite] Avoid division by zero.

Ilya Tocar tocarip.intel@gmail.com
Thu Jan 30 16:41:00 GMT 2014


Hi,
This patch removes possible division by zero.
Make check passes. Ok for trunk?

2014-01-30  Ilya Tocar  <ilya.tocar@intel.com>

	* gcc.target/i386/m512-check.h: Use correct rounding values.

---
 gcc/testsuite/gcc.target/i386/m512-check.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/gcc/testsuite/gcc.target/i386/m512-check.h b/gcc/testsuite/gcc.target/i386/m512-check.h
index 3209039..8441784 100644
--- a/gcc/testsuite/gcc.target/i386/m512-check.h
+++ b/gcc/testsuite/gcc.target/i386/m512-check.h
@@ -58,7 +58,8 @@ check_rough_##UINON_TYPE (UINON_TYPE u, const VALUE_TYPE *v,	\
 								\
   for (i = 0; i < ARRAY_SIZE (u.a); i++)			\
     {								\
-      VALUE_TYPE rel_err = (u.a[i] - v[i]) / v[i];		\
+      VALUE_TYPE rel_err;					\
+      rel_err = v[i] != 0 ? (u.a[i] - v[i]) / v[i] : u.a[i];	\
       if (((rel_err < 0) ? -rel_err : rel_err) > eps)		\
 	{							\
 	  err++;						\
-- 
1.8.3.1



More information about the Gcc-patches mailing list