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 07/02/14 02:14, Jakub Jelinek wrote:
Hi!

Most of this probably doesn't need explanation, just the
expand_sdiv_pow2 change - shift_cost only tracks shift counts to
MAX_BITS_PER_WORD (but, for consistency between e.g. i?86 and x86_64 -m32
we'd better use BITS_PER_WORD instead as in most other expmed.c places),
when called with larger values it is out of bounds access.  I believe
for multiword accesses, even when we don't have costs for it, and masking
will be typically cheaper (e.g. for double word you need two word ANDs,
while for double word shift unless there is a specialized instruction
for double word shifts one needs either a library routine or 3 shifts and
IOR).

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2014-07-02  Jakub Jelinek  <jakub@redhat.com>

	* gcov-io.c (gcov_read_words): Don't call memmove if excess is 0.
	* data-streamer-in.c (streamer_read_hwi): Shift UHWI 1 instead of
	HWI 1 and negate the unsigned value.
	* expmed.c (expand_sdiv_pow2): For modes wider than word always
	use AND instead of shift.
	* wide-int-print.cc (print_decs): Negate UHWI instead of HWI.
c-family/
	* c-ada-spec.c (dump_ada_nodes): Don't call qsort if
	comments->count <= 1, as comments->entries might be NULL.
OK for the trunk.

Thanks,
Jeff


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