This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[gccgo] Allocate correct size when taking address of result variable
- From: Ian Lance Taylor <iant at google dot com>
- To: gcc-patches at gcc dot gnu dot org, gofrontend-dev at googlegroups dot com
- Date: Sun, 27 Jun 2010 00:29:39 -0700
- Subject: [gccgo] Allocate correct size when taking address of result variable
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
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);