This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fix various undefined behaviors in gcc found by bootstrap-ubsan


On Jul 2, 2014, at 1:14 AM, Jakub Jelinek <jakub@redhat.com> wrote:
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

wide-int part, Ok.

> 	* wide-int-print.cc (print_decs): Negate UHWI instead of HWI.

> --- gcc/wide-int-print.cc.jj	2014-05-11 22:21:04.000000000 +0200
> +++ gcc/wide-int-print.cc	2014-06-30 12:02:11.349485371 +0200
> @@ -62,7 +62,8 @@ print_decs (const wide_int_ref &wi, char
>       || (wi.get_len () == 1))
>     {
>       if (wi::neg_p (wi))
> -      	sprintf (buf, "-" HOST_WIDE_INT_PRINT_UNSIGNED, -wi.to_shwi ());
> +      	sprintf (buf, "-" HOST_WIDE_INT_PRINT_UNSIGNED,
> +		 -(unsigned HOST_WIDE_INT) wi.to_shwi ());
>       else
> 	sprintf (buf, HOST_WIDE_INT_PRINT_DEC, wi.to_shwi ());
>     }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]