Patchwork [gccgo] Correct type of slice size passed to function

login
register
mail settings
Submitter Ian Taylor
Date June 27, 2010, 12:11 a.m.
Message ID <mcrd3vd1ghn.fsf@google.com>
Download mbox | patch
Permalink /patch/57079/
State New
Headers show

Comments

Ian Taylor - June 27, 2010, 12:11 a.m.
The size of a slice is stored as an int.  The builtin functions
__go_byte_array_to_string and __go_int_array_to_string currently take a
size_t argument.  This patch converts the size as required.  Committed
to gccgo branch.

Ian

Patch

diff -r adeb0f21cd0d go/expressions.cc
--- a/go/expressions.cc	Sat Jun 26 17:08:21 2010 -0700
+++ b/go/expressions.cc	Sat Jun 26 17:09:53 2010 -0700
@@ -3371,6 +3371,7 @@ 
       tree valptr = fold_convert(const_ptr_type_node,
 				 a->value_pointer_tree(gogo, expr_tree));
       tree len = a->length_tree(gogo, expr_tree);
+      len = fold_convert_loc(this->location(), size_type_node, len);
       if (e->integer_type()->is_unsigned()
 	  && e->integer_type()->bits() == 8)
 	{