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] 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;
     }
 

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