From patchwork Mon Apr 16 23:42:19 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 153013 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 CB0D6B6FF8 for ; Tue, 17 Apr 2012 09:46:11 +1000 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1335224773; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Received:Message-ID:Date:From:User-Agent:MIME-Version: To:CC:Subject:Content-Type:Mailing-List:Precedence:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:Sender: Delivered-To; bh=PdbUgFgwhLAKi3QvIN7x7DqyjU0=; b=LKZSIPycLXYsLJ4 UT0zOzk/rYj2mC5VkbjAdENZMrm24Wd0AJ8O/Fs4WZM0gSPrsTYBj1pbRiz0EiQa OsJX3qperwBNSkgmXofNaOmRlxfoKq8lD7L8DPbf3WBv3t1ZYHd1E0CrsHg1fRcl Og2lw2GlcYRCtvQIG6QY0RtWcvKs= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Received:Received:Message-ID:Date:From:User-Agent:MIME-Version:To:CC:Subject:Content-Type:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=p2axjeLK+3ZbSibOxROozAapJdlNfbvrj9BgcNQtIpbNuCqmj3q3KHBcf1uZsA HYKbsn/oYX8zTAyoevz8wd8iRhiaMJOhR0KP1J4hr5LcGe0IjLY+xHdHPSUoMoN5 iBAh0nxAukl97/PMj+9RY9JEJzxb7WV7zY1OydsdsBdb0=; Received: (qmail 418 invoked by alias); 16 Apr 2012 23:46:08 -0000 Received: (qmail 409 invoked by uid 22791); 16 Apr 2012 23:46:07 -0000 X-SWARE-Spam-Status: No, hits=-6.2 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_DNSWL_HI, RCVD_IN_HOSTKARMA_NO, RCVD_IN_HOSTKARMA_W, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from acsinet15.oracle.com (HELO acsinet15.oracle.com) (141.146.126.227) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 16 Apr 2012 23:45:55 +0000 Received: from ucsinet21.oracle.com (ucsinet21.oracle.com [156.151.31.93]) by acsinet15.oracle.com (Sentrion-MTA-4.2.2/Sentrion-MTA-4.2.2) with ESMTP id q3GNjqOt003368 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 16 Apr 2012 23:45:53 GMT Received: from acsmt357.oracle.com (acsmt357.oracle.com [141.146.40.157]) by ucsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id q3GNjp5V001107 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 16 Apr 2012 23:45:52 GMT Received: from abhmt120.oracle.com (abhmt120.oracle.com [141.146.116.72]) by acsmt357.oracle.com (8.12.11.20060308/8.12.11) with ESMTP id q3GNjpMW024896; Mon, 16 Apr 2012 18:45:51 -0500 Received: from [192.168.1.4] (/79.53.13.192) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 16 Apr 2012 16:45:51 -0700 Message-ID: <4F8CAE5B.40708@oracle.com> Date: Tue, 17 Apr 2012 01:42:19 +0200 From: Paolo Carlini User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:11.0) Gecko/20120312 Thunderbird/11.0 MIME-Version: 1.0 To: "gcc-patches@gcc.gnu.org" CC: Jason Merrill Subject: [C++ Patch] PR 53003 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 Hi, I had a look to this Segmentation fault in cp_parser_member_declaration and what happens is that initializer_token_start is still null (as initialized) when we get to: if (initializer) error_at (initializer_token_start->location, "pure-specifier on function-definition"); the trivial check avoids the Seg fault (and would be safe, for 4.7 too) but I'm not sure if we want to bail out a bit earlier. Tested x86_64-linux. Thanks, Paolo. //////////////////////// /cp 2012-04-16 Paolo Carlini PR c++/53003 * parser.c (cp_parser_member_declaration): Check that initializer_token_start is non null before dereferencing it. /testsuite 2012-04-16 Paolo Carlini PR c++/53003 * g++.dg/parse/crash59.C: New. Index: testsuite/g++.dg/parse/crash59.C =================================================================== --- testsuite/g++.dg/parse/crash59.C (revision 0) +++ testsuite/g++.dg/parse/crash59.C (revision 0) @@ -0,0 +1,3 @@ +// PR c++/53003 + +struct A{ void a{} return b // { dg-error "function definition|expected" } Index: cp/parser.c =================================================================== --- cp/parser.c (revision 186509) +++ cp/parser.c (working copy) @@ -19109,7 +19109,7 @@ cp_parser_member_declaration (cp_parser* parser) possible that this fact is an oversight in the standard, since a pure function may be defined outside of the class-specifier. */ - if (initializer) + if (initializer && initializer_token_start) error_at (initializer_token_start->location, "pure-specifier on function-definition"); decl = cp_parser_save_member_function_body (parser,