This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[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);

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]