Patchwork [gccgo] Allocate correct size when taking address of result variable

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

Comments

Ian Taylor - June 27, 2010, 7:29 a.m.
This patch fixes a dumb bug: when allocating space in the heap when
taking the address of a result variable, I was always allocating the
size of a pointer.  This corrects the code to allocate the amount of
space required to store the variable.  Committed to gccgo branch.

Ian

Patch

diff -r b621e0b91da7 go/gogo-tree.cc
--- a/go/gogo-tree.cc	Sat Jun 26 17:10:37 2010 -0700
+++ b/go/gogo-tree.cc	Sun Jun 27 00:27:25 2010 -0700
@@ -918,9 +918,9 @@ 
 	      init = type->get_init_tree(gogo, false);
 	    else
 	      {
-		result_type = build_pointer_type(result_type);
 		tree space = gogo->allocate_memory(TYPE_SIZE_UNIT(result_type),
 						   loc);
+		result_type = build_pointer_type(result_type);
 		tree subinit = type->get_init_tree(gogo, true);
 		if (subinit == NULL_TREE)
 		  init = fold_convert_loc(loc, result_type, space);