public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Fix division by 0 in printf_strlen_execute when dumping
@ 2020-12-03  1:06 Ilya Leoshkevich
  2020-12-03  2:35 ` Martin Sebor
  0 siblings, 1 reply; 2+ messages in thread
From: Ilya Leoshkevich @ 2020-12-03  1:06 UTC (permalink / raw)
  To: gcc-patches; +Cc: Martin Sebor, Ilya Leoshkevich

Bootstrap ang regtest running on x86_64-redhat-linux.  Ok for master?

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 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/tree-ssa-strlen.c b/gcc/tree-ssa-strlen.c
index 741b47bca4a..522b2d45b3a 100644
--- a/gcc/tree-ssa-strlen.c
+++ b/gcc/tree-ssa-strlen.c
@@ -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);
-- 
2.25.4


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Fix division by 0 in printf_strlen_execute when dumping
  2020-12-03  1:06 [PATCH] Fix division by 0 in printf_strlen_execute when dumping Ilya Leoshkevich
@ 2020-12-03  2:35 ` Martin Sebor
  0 siblings, 0 replies; 2+ messages in thread
From: Martin Sebor @ 2020-12-03  2:35 UTC (permalink / raw)
  To: Ilya Leoshkevich, gcc-patches; +Cc: Martin Sebor

On 12/2/20 6:06 PM, Ilya Leoshkevich via Gcc-patches wrote:
> Bootstrap ang regtest running on x86_64-redhat-linux.  Ok for master?

I'd consider the fix obviously correct.

Thank you!
Martin

> 
> 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 | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/gcc/tree-ssa-strlen.c b/gcc/tree-ssa-strlen.c
> index 741b47bca4a..522b2d45b3a 100644
> --- a/gcc/tree-ssa-strlen.c
> +++ b/gcc/tree-ssa-strlen.c
> @@ -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);
> 


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-12-03  2:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-03  1:06 [PATCH] Fix division by 0 in printf_strlen_execute when dumping Ilya Leoshkevich
2020-12-03  2:35 ` Martin Sebor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).