public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Fix PR82488 - signed integer overflow in expr.c
@ 2017-11-26 12:56 Markus Trippelsdorf
  2017-11-27  8:22 ` Jeff Law
  0 siblings, 1 reply; 2+ messages in thread
From: Markus Trippelsdorf @ 2017-11-26 12:56 UTC (permalink / raw)
  To: gcc-patches

bootstrap-ubsan shows:
 gcc/expr.c:4103:17: runtime error: signed integer overflow: 0 - -9223372036854775808 cannot be represented in type 'long int'

Fix by handling the saw_unknown case earlier.

bootstrap-ubsan on X86_64 and ppc64le. Tested on ppc64le.

OK for trunk?

	PR rtl-optimization/82488
	* expr.c (fixup_args_size_notes): Avoid signed integer overflow.


diff --git a/gcc/expr.c b/gcc/expr.c
index ee07de5aaa44..e9d8555c9452 100644
--- a/gcc/expr.c
+++ b/gcc/expr.c
@@ -4100,10 +4100,13 @@ fixup_args_size_notes (rtx_insn *prev, rtx_insn *last, int end_args_size)
       if (STACK_GROWS_DOWNWARD)
 	this_delta = -(unsigned HOST_WIDE_INT) this_delta;
 
-      args_size -= this_delta;
+      if (saw_unknown)
+	args_size = INT_MIN;
+      else
+	args_size -= this_delta;
     }
 
-  return saw_unknown ? INT_MIN : args_size;
+  return args_size;
 }
 
 #ifdef PUSH_ROUNDING
-- 
Markus

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

* Re: [PATCH] Fix PR82488 - signed integer overflow in expr.c
  2017-11-26 12:56 [PATCH] Fix PR82488 - signed integer overflow in expr.c Markus Trippelsdorf
@ 2017-11-27  8:22 ` Jeff Law
  0 siblings, 0 replies; 2+ messages in thread
From: Jeff Law @ 2017-11-27  8:22 UTC (permalink / raw)
  To: Markus Trippelsdorf, gcc-patches

On 11/26/2017 02:12 AM, Markus Trippelsdorf wrote:
> bootstrap-ubsan shows:
>  gcc/expr.c:4103:17: runtime error: signed integer overflow: 0 - -9223372036854775808 cannot be represented in type 'long int'
> 
> Fix by handling the saw_unknown case earlier.
> 
> bootstrap-ubsan on X86_64 and ppc64le. Tested on ppc64le.
> 
> OK for trunk?
> 
> 	PR rtl-optimization/82488
> 	* expr.c (fixup_args_size_notes): Avoid signed integer overflow.
OK.
jeff

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

end of thread, other threads:[~2017-11-27  3:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-26 12:56 [PATCH] Fix PR82488 - signed integer overflow in expr.c Markus Trippelsdorf
2017-11-27  8:22 ` Jeff Law

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).