diff --git a/gcc/ChangeLog b/gcc/ChangeLog index fcb9410ce03..3ebbc1cd13e 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2016-12-15 Martin Sebor + + PR bootstrap/78817 + * vec.h (vec::safe_grow_cleared): Assert + a pointer is non-null. + 2016-12-15 Andrew Senkevich * config/i386/avx512bwintrin.h: Add new k-mask intrinsics. diff --git a/gcc/vec.h b/gcc/vec.h index aa93411132b..3877f2d8ffe 100644 --- a/gcc/vec.h +++ b/gcc/vec.h @@ -1607,10 +1607,16 @@ inline void vec::safe_grow_cleared (unsigned len MEM_STAT_DECL) { unsigned oldlen = length (); - size_t sz = sizeof (T) * (len - oldlen); - safe_grow (len PASS_MEM_STAT); - if (sz != 0) - memset (&(address ()[oldlen]), 0, sz); + gcc_checking_assert (oldlen <= len); + + if (size_t sz = sizeof (T) * (len - oldlen)) + { + safe_grow (len PASS_MEM_STAT); + + T *p = address (); + gcc_assert (p != NULL); + memset (p + oldlen, 0, sz); + } }