don't try and free what must be a null vector when reserving 0 elements
authorTrevor Saunders <tsaunders@mozilla.com>
Tue, 5 Nov 2013 13:51:32 +0000 (13:51 +0000)
committerTrevor Saunders <tbsaunde@gcc.gnu.org>
Tue, 5 Nov 2013 13:51:32 +0000 (13:51 +0000)
in va_heap::reserve

2013-11-05  Trevor Saunders  <tsaunders@mozilla.com>

* vec.c (vec_prefix::calculate_allocation): Don't try to handle the
case of no prefix and reserving zero slots, because when that's the
case we'll never get here.
* vec.h (va_heap::reserve): Don't try and handle
vec_prefix::calculate_allocation returning zero because that should
never happen.

From-SVN: r204392

gcc/ChangeLog
gcc/vec.c
gcc/vec.h

index 757eded9a1422eefa346e85b9dd556d1f5344056..e388ec9660d961637aab181bd2435afd1006d8e4 100644 (file)
@@ -1,3 +1,12 @@
+2013-11-05  Trevor Saunders  <tsaunders@mozilla.com>
+
+       * vec.c (vec_prefix::calculate_allocation): Don't try to handle the
+       case of no prefix and reserving zero slots, because when that's the
+       case we'll never get here.
+       * vec.h (va_heap::reserve): Don't try and handle
+       vec_prefix::calculate_allocation returning zero because that should
+       never happen.
+
 2013-11-05  Richard Biener  <rguenther@suse.de>
 
        PR middle-end/58941
index f3c331507d55212ba8249ad03d082d6f33065f56..78252e0d0887df079b3461fb6947ee518d628231 100644 (file)
--- a/gcc/vec.c
+++ b/gcc/vec.c
@@ -187,9 +187,7 @@ vec_prefix::calculate_allocation (vec_prefix *pfx, unsigned reserve,
       num = pfx->m_num;
     }
   else if (!reserve)
-    /* If there's no vector, and we've not requested anything, then we
-       will create a NULL vector.  */
-    return 0;
+    gcc_unreachable ();
 
   /* We must have run out of room.  */
   gcc_assert (alloc - num < reserve);
index f97e022f24a5c06c341ccc7e4ee78c4f7a0d86d1..b1ebda44f5e17049d9f27da7f4523191a3b86f5c 100644 (file)
--- a/gcc/vec.h
+++ b/gcc/vec.h
@@ -283,11 +283,7 @@ va_heap::reserve (vec<T, va_heap, vl_embed> *&v, unsigned reserve, bool exact
 {
   unsigned alloc
     = vec_prefix::calculate_allocation (v ? &v->m_vecpfx : 0, reserve, exact);
-  if (!alloc)
-    {
-      release (v);
-      return;
-    }
+  gcc_assert (alloc);
 
   if (GATHER_STATISTICS && v)
     v->m_vecpfx.release_overhead ();