From 7bd1e2edf9a0456062dfd7cbc47b46d93239e997 Mon Sep 17 00:00:00 2001 From: Martin Sebor Date: Fri, 16 Dec 2016 02:57:22 +0000 Subject: [PATCH] PR bootstrap/78817 - stage2 bootstrap failure in vec.h:1613:5: error: argument 1 null where non-null expected after r243661 gcc/ChangeLog: * vec.h (vec::safe_grow_cleared): Assert a pointer is non-null. From-SVN: r243736 --- gcc/ChangeLog | 6 ++++++ gcc/vec.h | 14 ++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) 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); + } } -- 2.30.2