diff mbox

Go patch committed: Don't crash returning from '_' function

Message ID mcraajylnxr.fsf@google.com
State New
Headers show

Commit Message

Ian Lance Taylor Dec. 21, 2010, 11:13 p.m. UTC
The name '_' in Go is special and means that the object is ignored.  It
is possible to name a function '_'.  Gccgo would crash when a function
with that name had a return statement.  This patch fixes the crash by
giving the function a real name internally.  Bootstrapped and ran Go
testsuite on x86_64-unknown-linux-gnu.  Committed to mainline.

Ian
diff mbox

Patch

diff -r b430e050bd97 go/gogo.cc
--- a/go/gogo.cc	Tue Dec 21 14:57:39 2010 -0800
+++ b/go/gogo.cc	Tue Dec 21 15:06:39 2010 -0800
@@ -659,7 +659,13 @@ 
 
   Named_object* ret;
   if (Gogo::is_sink_name(*pname))
-    ret = Named_object::make_sink();
+    {
+      static int sink_count;
+      char buf[30];
+      snprintf(buf, sizeof buf, ".$sink%d", sink_count);
+      ++sink_count;
+      ret = Named_object::make_function(buf, NULL, function);
+    }
   else if (!type->is_method())
     {
       ret = this->package_->bindings()->add_function(*pname, NULL, function);