This trivial patch to the Go library fixes calling make on a slice of
elements whose size is zero.  Bootstrapped and ran Go testsuite on
x86_64-unknown-linux-gnu.  Committed to mainline.

Ian

diff -r ce7423ad4e50 libgo/runtime/go-make-slice.c
--- a/libgo/runtime/go-make-slice.c	Tue Sep 20 13:57:32 2011 -0700
+++ b/libgo/runtime/go-make-slice.c	Tue Sep 20 14:52:13 2011 -0700
@@ -35,7 +35,8 @@
   icap = (int) cap;
   if (cap < len
       || (uintptr_t) icap != cap
-      || cap > (uintptr_t) -1U / std->__element_type->__size)
+      || (std->__element_type->__size > 0
+	  && cap > (uintptr_t) -1U / std->__element_type->__size))
     __go_panic_msg ("makeslice: cap out of range");
 
   ret.__count = ilen;

Reply via email to