{"id":807010,"url":"http://patchwork.ozlabs.org/api/patches/807010/?format=json","web_url":"http://patchwork.ozlabs.org/project/gcc/patch/7c782ea8-b832-3e1b-ce83-cca08866f4c8@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":"<7c782ea8-b832-3e1b-ce83-cca08866f4c8@oracle.com>","list_archive_url":null,"date":"2017-08-29T09:33:55","name":"[C++] PR 70621 (\"[6/7/8 Regression] ICE on invalid code at -O1 and above on x86_64-linux-gnu in record_reference, at cgraphbuild.c:64\")","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"a9f649c8cfbabaadbf7824a75376fc547d01c4e3","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/7c782ea8-b832-3e1b-ce83-cca08866f4c8@oracle.com/mbox/","series":[{"id":333,"url":"http://patchwork.ozlabs.org/api/series/333/?format=json","web_url":"http://patchwork.ozlabs.org/project/gcc/list/?series=333","date":"2017-08-29T09:33:55","name":"[C++] PR 70621 (\"[6/7/8 Regression] ICE on invalid code at -O1 and above on x86_64-linux-gnu in record_reference, at cgraphbuild.c:64\")","version":1,"mbox":"http://patchwork.ozlabs.org/series/333/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/807010/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/807010/checks/","tags":{},"related":[],"headers":{"Return-Path":"<gcc-patches-return-461070-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-461070-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=\"tAjUZXx5\"; 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 3xhNkn0Q3bz9t2x\n\tfor <incoming@patchwork.ozlabs.org>;\n\tTue, 29 Aug 2017 19:34:24 +1000 (AEST)","(qmail 130877 invoked by alias); 29 Aug 2017 09:34:14 -0000","(qmail 130857 invoked by uid 89); 29 Aug 2017 09:34:12 -0000","from aserp1040.oracle.com (HELO aserp1040.oracle.com)\n\t(141.146.126.69) by sourceware.org\n\t(qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP;\n\tTue, 29 Aug 2017 09:34:02 +0000","from aserv0022.oracle.com (aserv0022.oracle.com\n\t[141.146.126.234])\tby aserp1040.oracle.com\n\t(Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id\n\tv7T9XxMr002954\t(version=TLSv1.2\n\tcipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK);\n\tTue, 29 Aug 2017 09:34:00 GMT","from userv0121.oracle.com (userv0121.oracle.com\n\t[156.151.31.72])\tby aserv0022.oracle.com (8.14.4/8.14.4) with\n\tESMTP id v7T9XxFW021097\t(version=TLSv1/SSLv3\n\tcipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK);\n\tTue, 29 Aug 2017 09:33:59 GMT","from abhmp0006.oracle.com (abhmp0006.oracle.com\n\t[141.146.116.12])\tby userv0121.oracle.com (8.14.4/8.13.8)\n\twith ESMTP id v7T9Xw9P012580; Tue, 29 Aug 2017 09:33:58 GMT","from [192.168.1.4] (/79.30.90.105)\tby default (Oracle Beehive\n\tGateway v4.0)\twith ESMTP ; Tue, 29 Aug 2017 02:33:58 -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=uKr0mHIsQeSVD1HRnYwEwu0dwpz+KXxKpxI2FdNVVrHIt5jAZE\n\t/jhrwLuGVTp8hzHOXN+2thfdaaywevNIB6rMFvp5WcBsH2SPBwzwctQ/56CfdoJ/\n\tKdkKm5dcgKWxmTccFt70BLma2jnWAxW+ZNMpKRbfw9Rti0IUDyisCt/QQ=","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=QhuBCUjyfTVQ2llzs8Y466gTJy0=; b=tAjUZXx5Ylyq55eY3zVS\n\t+UEVOGazkYhmSniozOghjJAYn/oPM8rl96OSMVBWNUDjn2sLhLSA8UMR4OSptu1B\n\tOO8bP+lXge3Mfbyjb8ArtVX6OFh0AzmSvpnCgHRuvbl2zIsDoX/jkPWQuyEqEceP\n\tsE29MiWmdscOAmb3SITt1V4=","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=-11.1 required=5.0 tests=BAYES_00, GIT_PATCH_2,\n\tGIT_PATCH_3, KAM_ASCII_DIVIDERS, RP_MATCHES_RCVD,\n\tSPF_PASS autolearn=ham version=3.3.2 spammy=(unknown),\n\tH*r:ip*192.168.1.4, Hx-spam-relays-external:192.168.1.4,\n\tH*RU:192.168.1.4","X-HELO":"aserp1040.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++ Patch] PR 70621 (\"[6/7/8 Regression] ICE on invalid code at\n\t-O1 and above on x86_64-linux-gnu in record_reference,\n\tat cgraphbuild.c:64\")","Message-ID":"<7c782ea8-b832-3e1b-ce83-cca08866f4c8@oracle.com>","Date":"Tue, 29 Aug 2017 11:33:55 +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=\"------------D61192B0FD49FB8B96670560\"","X-IsSubscribed":"yes"},"content":"Hi,\n\nin this error recovery regression, we ICE only when optimizing, while \nbuilding the cgraph. Avoiding the reported problem seems easy, just \ncheck the return value of duplicate_decls in start_decl and immediately \nreturn back error_mark_node. However, while working on the issue, I \nnoticed something slightly more interesting, IMO: we have, after the \nrelevant duplicate_decls call:\n\n-              if (decl_spec_seq_has_spec_p (declspecs, ds_constexpr)\n-                  && !DECL_DECLARED_CONSTEXPR_P (field))\n-                error (\"%qD declared %<constexpr%> outside its class\", \nfield);\n\nwhich I propose to remove. In fact - something I didn't really know - \nfor well formed user code, duplicate_decls, near the end, does some \nmemcpys which mean that its second argument (would be 'field' in the \nstart_decl section we are looking at)  is adjusted to have a \nDECL_DECLARED_CONSTEXPR_P consistent with its first argument. That's of \ncourse because we want to accept snippets like:\n\nstruct A\n{\n   static const int x;\n};\n\nconstexpr int A::x = 0;\n\nIn turn that means the error above is issued only when something went \nwrong in duplicate_decls in the first place. Thus the above error seems \nat least verbose. However, here in start_decl we are only handling VAR_P \n(decl), thus I don't think the message above even makes sense and could \nbe misleading, given snippets like the above. Therefore, I propose to \nremove the diagnostic entirely, which overall also simplifies a patch \ndealing with c++/70621. The below passes testing as-is on x86_64-linux.\n\nThanks, Paolo.\n\n////////////////////////\n/cp\n2017-29-08  Paolo Carlini  <paolo.carlini@oracle.com>\n\n\tPR c++/70621\n\t* decl.c (start_decl): Early return error_mark_node if duplicate_decls\n\treturns it; avoid misleading error message.\n\n/testsuite\n2017-29-08  Paolo Carlini  <paolo.carlini@oracle.com>\n\n\tPR c++/70621\n\t* g++.dg/torture/pr70621.C: New.","diff":"Index: cp/decl.c\n===================================================================\n--- cp/decl.c\t(revision 251375)\n+++ cp/decl.c\t(working copy)\n@@ -5023,11 +5023,12 @@ start_decl (const cp_declarator *declarator,\n \t\t about this situation, and so we check here.  */\n \t      if (initialized && DECL_INITIALIZED_IN_CLASS_P (field))\n \t\terror (\"duplicate initialization of %qD\", decl);\n-\t      if (duplicate_decls (decl, field, /*newdecl_is_friend=*/false))\n+\t      field = duplicate_decls (decl, field,\n+\t\t\t\t       /*newdecl_is_friend=*/false);\n+\t      if (field == error_mark_node)\n+\t\treturn error_mark_node;\n+\t      else if (field)\n \t\tdecl = field;\n-              if (decl_spec_seq_has_spec_p (declspecs, ds_constexpr)\n-                  && !DECL_DECLARED_CONSTEXPR_P (field))\n-                error (\"%qD declared %<constexpr%> outside its class\", field);\n \t    }\n \t}\n       else\nIndex: testsuite/g++.dg/torture/pr70621.C\n===================================================================\n--- testsuite/g++.dg/torture/pr70621.C\t(revision 0)\n+++ testsuite/g++.dg/torture/pr70621.C\t(working copy)\n@@ -0,0 +1,13 @@\n+float foo();\n+\n+struct A\n+{\n+  static float x;  // { dg-message \"previous declaration\" }\n+};\n+\n+double A::x = foo();  // { dg-error \"conflicting declaration\" }\n+\n+void bar()\n+{\n+  A::x = 0;\n+}\n","prefixes":["C++"]}