{"id":810070,"url":"http://patchwork.ozlabs.org/api/patches/810070/?format=json","web_url":"http://patchwork.ozlabs.org/project/gcc/patch/25f223e6-8b85-d81a-51f0-2dec92838338@oracle.com/","project":{"id":17,"url":"http://patchwork.ozlabs.org/api/projects/17/?format=json","name":"GNU Compiler Collection","link_name":"gcc","list_id":"gcc-patches.gcc.gnu.org","list_email":"gcc-patches@gcc.gnu.org","web_url":null,"scm_url":null,"webscm_url":null,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<25f223e6-8b85-d81a-51f0-2dec92838338@oracle.com>","list_archive_url":null,"date":"2017-09-05T10:19:33","name":"[C++/ARM] PR 81942 (\"ICE on empty constexpr constructor with C++14\")","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"0693a6082a21497dffa8628861a76e3382089ead","submitter":{"id":4341,"url":"http://patchwork.ozlabs.org/api/people/4341/?format=json","name":"Paolo Carlini","email":"paolo.carlini@oracle.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/gcc/patch/25f223e6-8b85-d81a-51f0-2dec92838338@oracle.com/mbox/","series":[{"id":1543,"url":"http://patchwork.ozlabs.org/api/series/1543/?format=json","web_url":"http://patchwork.ozlabs.org/project/gcc/list/?series=1543","date":"2017-09-05T10:19:33","name":"[C++/ARM] PR 81942 (\"ICE on empty constexpr constructor with C++14\")","version":1,"mbox":"http://patchwork.ozlabs.org/series/1543/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/810070/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/810070/checks/","tags":{},"related":[],"headers":{"Return-Path":"<gcc-patches-return-461475-incoming=patchwork.ozlabs.org@gcc.gnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":["patchwork-incoming@bilbo.ozlabs.org","mailing list gcc-patches@gcc.gnu.org"],"Authentication-Results":["ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org\n\t(client-ip=209.132.180.131; helo=sourceware.org;\n\tenvelope-from=gcc-patches-return-461475-incoming=patchwork.ozlabs.org@gcc.gnu.org;\n\treceiver=<UNKNOWN>)","ozlabs.org; dkim=pass (1024-bit key;\n\tunprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org\n\theader.b=\"am1mIzT+\"; dkim-atps=neutral","sourceware.org; auth=none"],"Received":["from sourceware.org (server1.sourceware.org [209.132.180.131])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xmjQ14VmJz9s3w\n\tfor <incoming@patchwork.ozlabs.org>;\n\tTue,  5 Sep 2017 20:19:53 +1000 (AEST)","(qmail 26617 invoked by alias); 5 Sep 2017 10:19:45 -0000","(qmail 26600 invoked by uid 89); 5 Sep 2017 10:19:43 -0000","from userp1040.oracle.com (HELO userp1040.oracle.com)\n\t(156.151.31.81) by sourceware.org\n\t(qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP;\n\tTue, 05 Sep 2017 10:19:38 +0000","from aserv0021.oracle.com (aserv0021.oracle.com\n\t[141.146.126.233])\tby userp1040.oracle.com\n\t(Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id\n\tv85AJaUh009833\t(version=TLSv1.2\n\tcipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK);\n\tTue, 5 Sep 2017 10:19:36 GMT","from aserv0121.oracle.com (aserv0121.oracle.com\n\t[141.146.126.235])\tby aserv0021.oracle.com (8.14.4/8.14.4)\n\twith ESMTP id v85AJZFO027769\t(version=TLSv1/SSLv3\n\tcipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK);\n\tTue, 5 Sep 2017 10:19:35 GMT","from abhmp0001.oracle.com (abhmp0001.oracle.com\n\t[141.146.116.7])\tby aserv0121.oracle.com (8.14.4/8.13.8) with\n\tESMTP id v85AJZRw003487; Tue, 5 Sep 2017 10:19:35 GMT","from [192.168.1.4] (/87.18.226.243)\tby default (Oracle Beehive\n\tGateway v4.0)\twith ESMTP ; Tue, 05 Sep 2017 03:19:35 -0700"],"DomainKey-Signature":"a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id\n\t:list-unsubscribe:list-archive:list-post:list-help:sender:to:cc\n\t:from:subject:message-id:date:mime-version:content-type; q=dns;\n\ts=default; b=Bdthfw2rX+gBWt2mjLjoeq80F/PsD52meovfA+wTon2YAxrAHL\n\tkvCsG/6D+CyxysHxqxDSo/Gk4NZkMyZTC8exrb6CMA4Cv9VktGVn9l/80QCb1Dz/\n\tUjfThJ9uVAJ3pyQp6r2AnYDRomiGs+8wn2gDIWL+OirRZyv8LLOQxe1gs=","DKIM-Signature":"v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id\n\t:list-unsubscribe:list-archive:list-post:list-help:sender:to:cc\n\t:from:subject:message-id:date:mime-version:content-type; s=\n\tdefault; bh=q3SvJk3u5MRoYy5EYnOArGZAPQk=; b=am1mIzT+hRa2Hp0aDXvR\n\ttk/Vubb6oBmmLMJ0kQ2xirPxUNQgbHtDGjsU1OHpR+ZIb3msoZhu2lFfcZLSD8nh\n\txI3vdPz9/67fMeTS/Zs+CeBoA0y3n7K6c6w011YGoLDAel2VwzTJUg/G4ZjBMl24\n\tujWzp8Mi0Ph88J7DrUSFnfM=","Mailing-List":"contact gcc-patches-help@gcc.gnu.org; run by ezmlm","Precedence":"bulk","List-Id":"<gcc-patches.gcc.gnu.org>","List-Unsubscribe":"<mailto:gcc-patches-unsubscribe-incoming=patchwork.ozlabs.org@gcc.gnu.org>","List-Archive":"<http://gcc.gnu.org/ml/gcc-patches/>","List-Post":"<mailto:gcc-patches@gcc.gnu.org>","List-Help":"<mailto:gcc-patches-help@gcc.gnu.org>","Sender":"gcc-patches-owner@gcc.gnu.org","X-Virus-Found":"No","X-Spam-SWARE-Status":"No, score=-10.1 required=5.0 tests=BAYES_00, GIT_PATCH_2,\n\tGIT_PATCH_3, KAM_ASCII_DIVIDERS, KAM_LAZY_DOMAIN_SECURITY,\n\tRP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=","X-HELO":"userp1040.oracle.com","To":"\"gcc-patches@gcc.gnu.org\" <gcc-patches@gcc.gnu.org>","Cc":"Jason Merrill <jason@redhat.com>","From":"Paolo Carlini <paolo.carlini@oracle.com>","Subject":"[C++/ARM Patch] PR 81942 (\"ICE on empty constexpr constructor with\n\tC++14\")","Message-ID":"<25f223e6-8b85-d81a-51f0-2dec92838338@oracle.com>","Date":"Tue, 5 Sep 2017 12:19:33 +0200","User-Agent":"Mozilla/5.0 (X11; Linux x86_64;\n\trv:52.0) Gecko/20100101 Thunderbird/52.1.0","MIME-Version":"1.0","Content-Type":"multipart/mixed;\n\tboundary=\"------------884BD055B1FD89EEF2987349\"","X-IsSubscribed":"yes"},"content":"Hi,\n\nHi,\n\nin this ICE on valid, a gcc_assert fires when a GOTO_EXPR is handled by \ncxx_eval_constant_expression which is the translation of a \"return;\" on \na targetm.cxx.cdtor_returns_this target (like ARM):\n\n;; Function constexpr A::A() (null)\n;; enabled by -tree-original\n\n\n{\n   // predicted unlikely by goto predictor.;\n   goto <D.4600>;\n}\n<D.4600>:;\nreturn this;\n\nI think the right way to handle this is marking such special labels with \na LABEL_DECL_CDTOR flag and using it in the returns helper function (we \nalready use a similar strategy with LABEL_DECL_BREAK and \nLABEL_DECL_CONTINUE and the breaks and continues helpers). Then \nadjusting the ICEing gcc_assert is trivial. Tested x86_64-linux and \naarch64-linux.\n\nThanks,\nPaolo.\n\n//////////////////////////////////\n/cp\n2017-09-05  Paolo Carlini  <paolo.carlini@oracle.com>\n\n\tPR c++/81942\n\t* cp-tree.h (LABEL_DECL_CDTOR): Add and document.\n\t* decl.c (start_preparsed_function): Set LABEL_DECL_CDTOR when\n\tcreating cdtor_label.\n\t* constexpr.c (returns): Add the case of a constructor/destructor\n\treturning via a LABEL_DECL_CDTOR label.\n\t(cxx_eval_constant_expression, case [GOTO_EXPR]): Likewise.\n\n/testsuite\n2017-09-05  Paolo Carlini  <paolo.carlini@oracle.com>\n\n\tPR c++/81942\n\t* g++.dg/cpp1y/constexpr-return3.C: New.","diff":"Index: cp/constexpr.c\n===================================================================\n--- cp/constexpr.c\t(revision 251700)\n+++ cp/constexpr.c\t(working copy)\n@@ -3671,7 +3671,9 @@ static bool\n returns (tree *jump_target)\n {\n   return *jump_target\n-    && TREE_CODE (*jump_target) == RETURN_EXPR;\n+    && (TREE_CODE (*jump_target) == RETURN_EXPR\n+\t|| (TREE_CODE (*jump_target) == LABEL_DECL\n+\t    && LABEL_DECL_CDTOR (*jump_target)));\n }\n \n static bool\n@@ -4554,7 +4556,9 @@ cxx_eval_constant_expression (const constexpr_ctx\n \n     case GOTO_EXPR:\n       *jump_target = TREE_OPERAND (t, 0);\n-      gcc_assert (breaks (jump_target) || continues (jump_target));\n+      gcc_assert (breaks (jump_target) || continues (jump_target)\n+\t\t  /* Allow for jumping to a cdtor_label.  */\n+\t\t  || returns (jump_target));\n       break;\n \n     case LOOP_EXPR:\nIndex: cp/cp-tree.h\n===================================================================\n--- cp/cp-tree.h\t(revision 251700)\n+++ cp/cp-tree.h\t(working copy)\n@@ -456,6 +456,7 @@ extern GTY(()) tree cp_global_trees[CPTI_MAX];\n       DECL_CONSTRAINT_VAR_P (in a PARM_DECL)\n       TEMPLATE_DECL_COMPLEX_ALIAS_P (in TEMPLATE_DECL)\n       DECL_INSTANTIATING_NSDMI_P (in a FIELD_DECL)\n+      LABEL_DECL_CDTOR (in LABEL_DECL)\n    3: DECL_IN_AGGR_P.\n    4: DECL_C_BIT_FIELD (in a FIELD_DECL)\n       DECL_ANON_UNION_VAR_P (in a VAR_DECL)\n@@ -3833,6 +3834,11 @@ more_aggr_init_expr_args_p (const aggr_init_expr_a\n #define LABEL_DECL_CONTINUE(NODE) \\\n   DECL_LANG_FLAG_1 (LABEL_DECL_CHECK (NODE))\n \n+/* Nonzero if NODE is the target for genericization of 'return' stmts\n+   in constructors/destructors of targetm.cxx.cdtor_returns_this targets.  */\n+#define LABEL_DECL_CDTOR(NODE) \\\n+  DECL_LANG_FLAG_2 (LABEL_DECL_CHECK (NODE))\n+\n /* True if NODE was declared with auto in its return type, but it has\n    started compilation and so the return type might have been changed by\n    return type deduction; its declared return type should be found in\nIndex: cp/decl.c\n===================================================================\n--- cp/decl.c\t(revision 251700)\n+++ cp/decl.c\t(working copy)\n@@ -15072,7 +15073,10 @@ start_preparsed_function (tree decl1, tree attrs,\n   if (DECL_DESTRUCTOR_P (decl1)\n       || (DECL_CONSTRUCTOR_P (decl1)\n \t  && targetm.cxx.cdtor_returns_this ()))\n-    cdtor_label = create_artificial_label (input_location);\n+    {\n+      cdtor_label = create_artificial_label (input_location);\n+      LABEL_DECL_CDTOR (cdtor_label) = true;\n+    }\n \n   start_fname_decls ();\n \nIndex: testsuite/g++.dg/cpp1y/constexpr-return3.C\n===================================================================\n--- testsuite/g++.dg/cpp1y/constexpr-return3.C\t(revision 0)\n+++ testsuite/g++.dg/cpp1y/constexpr-return3.C\t(working copy)\n@@ -0,0 +1,11 @@\n+// PR c++/81942\n+// { dg-do compile { target c++14 } }\n+\n+class A {\n+public:\n+    constexpr A() {\n+      return;\n+    }\n+};\n+\n+A mwi;\n","prefixes":["C++/ARM"]}