From patchwork Wed Jun 30 21:32:27 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Lance Taylor X-Patchwork-Id: 57455 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 474F0B6F15 for ; Thu, 1 Jul 2010 07:32:41 +1000 (EST) Received: (qmail 23456 invoked by alias); 30 Jun 2010 21:32:39 -0000 Received: (qmail 23444 invoked by uid 22791); 30 Jun 2010 21:32:38 -0000 X-SWARE-Spam-Status: No, hits=-2.3 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, SPF_HELO_PASS, TW_CC, T_RP_MATCHES_RCVD, T_TVD_MIME_NO_HEADERS X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (216.239.44.51) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 30 Jun 2010 21:32:34 +0000 Received: from hpaq6.eem.corp.google.com (hpaq6.eem.corp.google.com [172.25.149.6]) by smtp-out.google.com with ESMTP id o5ULWWqm030757 for ; Wed, 30 Jun 2010 14:32:32 -0700 Received: from pwi10 (pwi10.prod.google.com [10.241.219.10]) by hpaq6.eem.corp.google.com with ESMTP id o5ULVt23001143 for ; Wed, 30 Jun 2010 14:32:30 -0700 Received: by pwi10 with SMTP id 10so495685pwi.20 for ; Wed, 30 Jun 2010 14:32:30 -0700 (PDT) Received: by 10.142.209.15 with SMTP id h15mr11009765wfg.150.1277933550333; Wed, 30 Jun 2010 14:32:30 -0700 (PDT) Received: from coign.google.com (dhcp-172-22-126-240.mtv.corp.google.com [172.22.126.240]) by mx.google.com with ESMTPS id c16sm6227119rvn.1.2010.06.30.14.32.28 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 30 Jun 2010 14:32:29 -0700 (PDT) From: Ian Lance Taylor To: gcc-patches@gcc.gnu.org, gofrontend-dev@googlegroups.com Subject: [gccgo] A type assertion with nil does not succeed Date: Wed, 30 Jun 2010 14:32:27 -0700 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) MIME-Version: 1.0 X-System-Of-Record: true X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org 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; }