Fix division by 0 in printf_strlen_execute when dumping
authorIlya Leoshkevich <iii@linux.ibm.com>
Thu, 3 Dec 2020 01:01:16 +0000 (02:01 +0100)
committerIlya Leoshkevich <iii@linux.ibm.com>
Thu, 3 Dec 2020 09:48:20 +0000 (10:48 +0100)
gcc/ChangeLog:

2020-12-03  Ilya Leoshkevich  <iii@linux.ibm.com>

* tree-ssa-strlen.c (printf_strlen_execute): Avoid division by
0.

gcc/tree-ssa-strlen.c

index 741b47bca4a6571743bc7be4c8b28a3c9d54cb78..522b2d45b3a198556a59fe9a1b05978dfe17278a 100644 (file)
@@ -5684,7 +5684,7 @@ printf_strlen_execute (function *fun, bool warn_only)
               "  failures:          %u\n"
               "  max_depth:         %u\n",
               nidxs,
-              (nused * 100) / nidxs,
+              nidxs == 0 ? 0 : (nused * 100) / nidxs,
               walker.ptr_qry.var_cache->access_refs.length (),
               walker.ptr_qry.hits, walker.ptr_qry.misses,
               walker.ptr_qry.failures, walker.ptr_qry.max_depth);