diff mbox

Fix PR68636

Message ID alpine.LSU.2.11.1512040911350.4884@t29.fhfr.qr
State New
Headers show

Commit Message

Richard Biener Dec. 4, 2015, 8:12 a.m. UTC
When we compute excessive byte alignment get_pointer_alignment_1
may end up returning an alignment of zero due to overflow when
multiplying with BITS_PER_UNIT.  This in turn causes get_object_alignment
to return a too conservative (byte) alignment.

Fixed as follows.

Bootstrapped and tested on x86_64-unknown-linux-gnu, applied.

Richard.

2015-12-04  Richard Biener  <rguenther@suse.de>

	PR middle-end/68636
	* builtins.c (get_pointer_alignment_1): Take care of byte to
	bit alignment computation overflow.
diff mbox

Patch

Index: gcc/builtins.c
===================================================================
--- gcc/builtins.c	(revision 231058)
+++ gcc/builtins.c	(working copy)
@@ -497,6 +497,10 @@  get_pointer_alignment_1 (tree exp, unsig
 	{
 	  *bitposp = ptr_misalign * BITS_PER_UNIT;
 	  *alignp = ptr_align * BITS_PER_UNIT;
+	  /* Make sure to return a sensible alignment when the multiplication
+	     by BITS_PER_UNIT overflowed.  */
+	  if (*alignp == 0)
+	    *alignp = 1u << (HOST_BITS_PER_INT - 1);
 	  /* We cannot really tell whether this result is an approximation.  */
 	  return true;
 	}