From patchwork Wed Jun 30 21:32:27 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [gccgo] A type assertion with nil does not succeed Date: Wed, 30 Jun 2010 11:32:27 -0000 From: Ian Taylor X-Patchwork-Id: 57455 Message-Id: To: gcc-patches@gcc.gnu.org, gofrontend-dev@googlegroups.com When doing a type assertion such as if v, ok := x.(t); ok { } where x is nil, the type assertion is not considered to succeed. This is true even though v := x.(t) does not cause a panic. This patch implements that for gccgo. Committed to gccgo branch. Ian diff -r 509de793fde1 libgo/runtime/go-convert-interface.c --- a/libgo/runtime/go-convert-interface.c Wed Jun 30 14:07:44 2010 -0700 +++ b/libgo/runtime/go-convert-interface.c Wed Jun 30 14:29:05 2010 -0700 @@ -35,7 +35,7 @@ if (rhs == NULL) { if (success != NULL) - *success = 1; + *success = 0; return NULL; }