This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Go patch committed: Don't crash returning from '_' function
- 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: Tue, 21 Dec 2010 15:13:20 -0800
- Subject: Go patch committed: Don't crash returning from '_' function
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 -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);