🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: gmane.comp.gcc.patches
2 messages
2 total messages Started by Jakub Jelinek Tue, 25 Mar 2014 08:09
[PATCH] Fix two spots with undefined behavior
#307928
Author: Jakub Jelinek
Date: Tue, 25 Mar 2014 08:09
38 lines
1206 bytes
Hi!

These two spots were determined by --with-build-config=bootstrap-ubsan
as having undefined signed integer overflow.

Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux,
ok for trunk?

2014-03-25  Jakub Jelinek  <jakub@redhat.com>

	* cselib.c (cselib_hash_rtx): Perform addition in unsigned
	type to avoid signed integer overflow.
	* explow.c (plus_constant): Likewise.

--- gcc/cselib.c.jj	2014-03-12 10:13:41.000000000 +0100
+++ gcc/cselib.c	2014-03-22 08:30:21.622829993 +0100
@@ -1137,7 +1137,7 @@ cselib_hash_rtx (rtx x, int create, enum
       return hash ? hash : (unsigned int) ENTRY_VALUE;

     case CONST_INT:
-      hash += ((unsigned) CONST_INT << 7) + INTVAL (x);
+      hash += ((unsigned) CONST_INT << 7) + UINTVAL (x);
       return hash ? hash : (unsigned int) CONST_INT;

     case CONST_DOUBLE:
--- gcc/explow.c.jj	2014-01-03 11:40:57.000000000 +0100
+++ gcc/explow.c	2014-03-22 08:31:42.379409989 +0100
@@ -110,7 +110,7 @@ plus_constant (enum machine_mode mode, r
 	  return immed_double_int_const (v, mode);
 	}

-      return gen_int_mode (INTVAL (x) + c, mode);
+      return gen_int_mode (UINTVAL (x) + c, mode);

     case CONST_DOUBLE:
       {

	Jakub
Re: [PATCH] Fix two spots with undefined behavior
#307941
Author: Richard Biener
Date: Tue, 25 Mar 2014 10:05
53 lines
1523 bytes
On Tue, 25 Mar 2014, Jakub Jelinek wrote:

> Hi!
>
> These two spots were determined by --with-build-config=bootstrap-ubsan
> as having undefined signed integer overflow.
>
> Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux,
> ok for trunk?

Ok.

Thanks,
Richard.

> 2014-03-25  Jakub Jelinek  <jakub@redhat.com>
>
> 	* cselib.c (cselib_hash_rtx): Perform addition in unsigned
> 	type to avoid signed integer overflow.
> 	* explow.c (plus_constant): Likewise.
>
> --- gcc/cselib.c.jj	2014-03-12 10:13:41.000000000 +0100
> +++ gcc/cselib.c	2014-03-22 08:30:21.622829993 +0100
> @@ -1137,7 +1137,7 @@ cselib_hash_rtx (rtx x, int create, enum
>        return hash ? hash : (unsigned int) ENTRY_VALUE;
>
>      case CONST_INT:
> -      hash += ((unsigned) CONST_INT << 7) + INTVAL (x);
> +      hash += ((unsigned) CONST_INT << 7) + UINTVAL (x);
>        return hash ? hash : (unsigned int) CONST_INT;
>
>      case CONST_DOUBLE:
> --- gcc/explow.c.jj	2014-01-03 11:40:57.000000000 +0100
> +++ gcc/explow.c	2014-03-22 08:31:42.379409989 +0100
> @@ -110,7 +110,7 @@ plus_constant (enum machine_mode mode, r
>  	  return immed_double_int_const (v, mode);
>  	}
>
> -      return gen_int_mode (INTVAL (x) + c, mode);
> +      return gen_int_mode (UINTVAL (x) + c, mode);
>
>      case CONST_DOUBLE:
>        {
>
> 	Jakub
>
>

--
Richard Biener <rguenther@suse.de>
SUSE / SUSE Labs
SUSE LINUX Products GmbH - Nuernberg - AG Nuernberg - HRB 16746
GF: Jeff Hawn, Jennifer Guild, Felix Imend"orffer
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads