From patchwork Mon Nov 21 15:38:36 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 697292 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 3tMt7D6Kqmz9t1B for ; Tue, 22 Nov 2016 02:39:03 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="BOTb4+rO"; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to:cc :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=SYyJSFiu/CWvY4nUp4S3jAkNrknKayGnNHB8LITMZH3psSjY6s CEGm843u3d0afswkMq193tpzIrfdW2dENYvgU+q/dNcr9LK71qXPy+nioP1fFwfO FBa41L3uZAYa6GMFY2+bOFpLRE3YIGcVm60mmtLXGVul0/fP/pgLVrmGE= 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:to:cc :from:subject:message-id:date:mime-version:content-type; s= default; bh=F3aSyG/sorEhXGYR36mypkoKXjY=; b=BOTb4+rOLd0/sQ/p7A2E 1Yj5b/0vxB9Tm9fPwKkxEKcUEE7Teb8PZQf1dD+MWYk66B4SPkgoyjDHDeX17mJM OBii5iTmKtmOSuESrCGGy4eMyLoVXShVYsCzNiLGNYq2Jk0GDrAPOdj+UoUFvnix zPkvCGU8um9LQj5hUDIxH3E= Received: (qmail 87041 invoked by alias); 21 Nov 2016 15:38:53 -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 86925 invoked by uid 89); 21 Nov 2016 15:38:52 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.1 required=5.0 tests=BAYES_00, KAM_ASCII_DIVIDERS, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 spammy=spending, BLK, among X-HELO: userp1040.oracle.com Received: from userp1040.oracle.com (HELO userp1040.oracle.com) (156.151.31.81) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 21 Nov 2016 15:38:42 +0000 Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id uALFcd3X020985 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 21 Nov 2016 15:38:40 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id uALFcdKp021732 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 21 Nov 2016 15:38:39 GMT Received: from abhmp0008.oracle.com (abhmp0008.oracle.com [141.146.116.14]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id uALFcdOA019928; Mon, 21 Nov 2016 15:38:39 GMT Received: from [192.168.1.4] (/79.53.233.60) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 21 Nov 2016 07:38:39 -0800 To: "gcc-patches@gcc.gnu.org" Cc: Jason Merrill From: Paolo Carlini Subject: [C++ Patch/RFC] PR 77545 ("[7 Regression] ICE on valid C++11 code: in potential_constant_expression_1..") Message-ID: <54310d9f-afcf-020f-ed96-5c3e3fd00358@oracle.com> Date: Mon, 21 Nov 2016 16:38:36 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 X-IsSubscribed: yes Hi, I have been spending some time on this regression, where we ICE in potential_constant_expression_1 because CLEANUP_STMT is unhandled. Apparently the ICE started with https://gcc.gnu.org/viewcvs/gcc?view=revision&revision=238559, where we started calling maybe_constant_value from cp_fully_fold, but now happens in the same way with that commit reverted too. The context of the ICE is the following: from store_init_value we call maybe_constant_init for a __for_range VAR_DECL as decl and a COMPUND_EXPR as value: needs-constructing type_4 BLK size unit size align 32 symtab 0 alias set -1 canonical type 0x7ffff69d9f18 domain pointer_to_this reference_to_this > private unsigned DI size unit size align 64 symtab 0 alias set -1 canonical type 0x7ffff69de690> side-effects arg 0 > side-effects head 0x7ffff69d3e28 tail 0x7ffff69d3e40 stmts 0x7ffff69d5e60 0x7ffff6855bd0 stmt side-effects tree_1 arg 0 side-effects arg 0 side-effects arg 0 arg 0 arg 1 > arg 1 > 77545.C:10:35 start: 77545.C:10:35 finish: 77545.C:10:35> 77545.C:10:35 start: 77545.C:10:35 finish: 77545.C:10:35> stmt side-effects static tree_1 arg 0 head (nil) tail (nil) stmts > arg 1 side-effects nothrow fn constant arg 0 > arg 0 arg 0 arg 0 >>> 77545.C:10:35 start: 77545.C:10:35 finish: 77545.C:10:35>> arg 1 arg 0 arg 0 >>> then, obviously, a bit later potential_constant_expression_1 stumbles into the CLEANUP_STMT among the statements in the STATEMENT_LIST we pass as ARG 0 of the COMPOUND_EXPR. I have been investigating how we build and handle CLEANUP_STMTs in constexpr.c (see in particular the comment at the beginning of build_data_member_initialization) and wondering if simply returning true for it from potential_constant_expression_1 wouldn't be correct... Certainly passes testing. Thanks for any feedback! Paolo. /////////////////////////// Index: cp/constexpr.c =================================================================== --- cp/constexpr.c (revision 242657) +++ cp/constexpr.c (working copy) @@ -4915,6 +4915,7 @@ potential_constant_expression_1 (tree t, bool want case CONTINUE_STMT: case REQUIRES_EXPR: case STATIC_ASSERT: + case CLEANUP_STMT: return true; case AGGR_INIT_EXPR: Index: testsuite/g++.dg/cpp0x/range-for32.C =================================================================== --- testsuite/g++.dg/cpp0x/range-for32.C (revision 0) +++ testsuite/g++.dg/cpp0x/range-for32.C (working copy) @@ -0,0 +1,16 @@ +// PR c++/77545 +// { dg-do compile { target c++11 } } +// { dg-options "" } + +template < typename T > struct A +{ + A (); + ~A (); + T t; +}; + +void f (A < int > a) +{ + for (auto x : (A < int >[]) { a }) + ; +}