This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[gccgo] A type assertion with nil does not succeed
- 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: Wed, 30 Jun 2010 14:32:27 -0700
- Subject: [gccgo] A type assertion with nil does not succeed
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;
}