From patchwork Fri Mar 28 05:20:54 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Lance Taylor X-Patchwork-Id: 334586 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id BA0AF14007E for ; Fri, 28 Mar 2014 16:21:08 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type; q=dns; s= default; b=N8yVqwVyeUg6a0uiz2FdnJiYzdL7uelrku+lTGUPvYf9Q3yZbcDoM l5hOIcwsKJzxd0+vVMj8A4XqWaVunpqV/IMS5ihTyMtOE7QBs7F0NP7UdlIXR63V IJGFXV9n8atmfqAMRXymtiULwU9C8o7yDF+9EaGpqzCKbHP9a352kc= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type; s= default; bh=8+D7MiIjqZEumNuslQWPA4StrCU=; b=XSCzef+MaKrfmz2Ey3G0 XrUWVEYfORSwnj1ZmO2oh69j6Gd7kad5tbq9o+dmBv/FPpes0eUh3NhET5Ki9rM2 0l+YFpvDs+8lmW4kI0m+j7mxoj8/6yPDptvr7MT7AgEliJGhdRQvTrfsEjsr0gDw QwofYSlRrMznt9yQ23gg0d4= Received: (qmail 724 invoked by alias); 28 Mar 2014 05:21:01 -0000 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 Received: (qmail 714 invoked by uid 89); 28 Mar 2014 05:21:00 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, RP_MATCHES_RCVD, SPF_PASS, T_TVD_MIME_NO_HEADERS autolearn=ham version=3.3.2 X-HELO: mail-pb0-f44.google.com Received: from mail-pb0-f44.google.com (HELO mail-pb0-f44.google.com) (209.85.160.44) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Fri, 28 Mar 2014 05:20:59 +0000 Received: by mail-pb0-f44.google.com with SMTP id rp16so4497122pbb.17 for ; Thu, 27 Mar 2014 22:20:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:user-agent :mime-version:content-type; bh=7jdyKTRJ/iG6LUVEa1UZWciipkc1JLgX4bdY+0urYTE=; b=LjKSVmhHyp0Esu7ApDHcwHyou3r4uQnsZTRpdmGMn1BSvWhBveAqw3G2G5xWcdo8fx 8FvN5FSaOtjbxiMR6oG1TKb0LiGq/Qad9vK92nlFUI21GGT2yQQWzPTodUhB56PMNq8l 7JWJxjOT675n1uKhcYMw+V6xSVJMM2B35fDWJkQLxlk2MH0vQnpHaSXzA1KMWf9Os169 PArAFCH9L4NFKLNQrI0qZFsyhTNwYskzottKheEKu+cu8HY7pN9Yjtst7J9APhpif00A dtqG8DJ2D/zE2Q7bgQy6nimea+Cw3wdsFMWUWY730t9FbNxGuhDW2WZghfp8l0NiZQxS S6ng== X-Gm-Message-State: ALoCoQkhruT/VuUvt7KqFC/oq9yLdyoORvZqspzvKMctoYbi9g368aBNhmC8cfF76PQzY5awgbgOwehzPZtPQ36LDA+KYHCj8T21k+Oq84ci1ZodFN1FDS6Qz4kzxszFK+QvgrD6JSGRGeFApGaDyT5hgKTlKQEbsUKGtq3r1fgzVRp0oxZPMFvaMLV5q+q9Nsrk9cHbjIdZhsAu/wAv31Rmo2a/tCaTWg== X-Received: by 10.68.138.165 with SMTP id qr5mr6251021pbb.123.1395984057244; Thu, 27 Mar 2014 22:20:57 -0700 (PDT) Received: from iant-glaptop.roam.corp.google.com.google.com ([172.19.244.127]) by mx.google.com with ESMTPSA id yv5sm17527304pbb.49.2014.03.27.22.20.55 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 27 Mar 2014 22:20:56 -0700 (PDT) From: Ian Lance Taylor To: gcc-patches@gcc.gnu.org, gofrontend-dev@googlegroups.com Subject: Go patch committed: Avoid reading bogus field Date: Thu, 27 Mar 2014 22:20:54 -0700 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux) MIME-Version: 1.0 X-IsSubscribed: yes PR 59545 points out that there is a case where the Go frontend reads an invalid value from a class field. This happens because of an incorrect static_cast. This patch fixes the problem to only use the static_cast when it is valid. Bootstrapped and ran Go tests on x86_64-unknown-linux-gnu. Committed to mainline. Ian diff -r 55fb8756d889 go/expressions.cc --- a/go/expressions.cc Thu Mar 27 14:22:49 2014 -0700 +++ b/go/expressions.cc Thu Mar 27 22:11:25 2014 -0700 @@ -4163,8 +4163,12 @@ go_assert(!this->expr_->is_composite_literal() || this->expr_->is_immutable()); - Unary_expression* ue = static_cast(this->expr_); - go_assert(ue == NULL || ue->op() != OPERATOR_AND); + if (this->expr_->classification() == EXPRESSION_UNARY) + { + Unary_expression* ue = + static_cast(this->expr_); + go_assert(ue->op() != OPERATOR_AND); + } } // Build a decl for a constant constructor.