From patchwork Tue Dec 21 22:58:48 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: 76340 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 76D3AB70A4 for ; Wed, 22 Dec 2010 09:59:06 +1100 (EST) Received: (qmail 28224 invoked by alias); 21 Dec 2010 22:59:00 -0000 Received: (qmail 28188 invoked by uid 22791); 21 Dec 2010 22:58:59 -0000 X-SWARE-Spam-Status: No, hits=-2.9 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, SPF_HELO_PASS, 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) (74.125.121.67) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 21 Dec 2010 22:58:55 +0000 Received: from wpaz17.hot.corp.google.com (wpaz17.hot.corp.google.com [172.24.198.81]) by smtp-out.google.com with ESMTP id oBLMwqdh003527 for ; Tue, 21 Dec 2010 14:58:52 -0800 Received: from pvc22 (pvc22.prod.google.com [10.241.209.150]) by wpaz17.hot.corp.google.com with ESMTP id oBLMwosg023672 for ; Tue, 21 Dec 2010 14:58:50 -0800 Received: by pvc22 with SMTP id 22so1205872pvc.41 for ; Tue, 21 Dec 2010 14:58:50 -0800 (PST) Received: by 10.143.18.7 with SMTP id v7mr4956993wfi.254.1292972330315; Tue, 21 Dec 2010 14:58:50 -0800 (PST) Received: from coign.google.com (dhcp-172-22-122-207.mtv.corp.google.com [172.22.122.207]) by mx.google.com with ESMTPS id e14sm8178562wfg.20.2010.12.21.14.58.49 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 21 Dec 2010 14:58:49 -0800 (PST) From: Ian Lance Taylor To: gcc-patches@gcc.gnu.org, gofrontend-dev@googlegroups.com Subject: Go patch committed: Don't crash indexing into erroneous array Date: Tue, 21 Dec 2010 14:58:48 -0800 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 This patch fixes the Go compiler to not crash when indexing into an erroneous array. Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu. Committed to mainline. Ian diff -r 4942fa9d5d0e go/expressions.cc --- a/go/expressions.cc Tue Dec 21 14:54:39 2010 -0800 +++ b/go/expressions.cc Tue Dec 21 14:56:49 2010 -0800 @@ -9154,7 +9154,11 @@ source_location loc = this->location(); Array_type* array_type = this->array_->type()->array_type(); - gcc_assert(array_type != NULL); + if (array_type == NULL) + { + gcc_assert(this->array_->type()->is_error_type()); + return error_mark_node; + } tree type_tree = array_type->get_tree(gogo); if (type_tree == error_mark_node)