{"id":2223617,"url":"http://patchwork.ozlabs.org/api/1.1/patches/2223617/?format=json","web_url":"http://patchwork.ozlabs.org/project/gcc/patch/20260415183539.1303758-1-polacek@redhat.com/","project":{"id":17,"url":"http://patchwork.ozlabs.org/api/1.1/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},"msgid":"<20260415183539.1303758-1-polacek@redhat.com>","date":"2026-04-15T18:35:39","name":"c++: ICE with deleted main [PR120338]","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"36473920e92123f6a8b889d5808920dd6ed2e9f9","submitter":{"id":14370,"url":"http://patchwork.ozlabs.org/api/1.1/people/14370/?format=json","name":"Marek Polacek","email":"polacek@redhat.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/gcc/patch/20260415183539.1303758-1-polacek@redhat.com/mbox/","series":[{"id":500028,"url":"http://patchwork.ozlabs.org/api/1.1/series/500028/?format=json","web_url":"http://patchwork.ozlabs.org/project/gcc/list/?series=500028","date":"2026-04-15T18:35:39","name":"c++: ICE with deleted main [PR120338]","version":1,"mbox":"http://patchwork.ozlabs.org/series/500028/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2223617/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2223617/checks/","tags":{},"headers":{"Return-Path":"<gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org>","X-Original-To":["incoming@patchwork.ozlabs.org","gcc-patches@gcc.gnu.org"],"Delivered-To":["patchwork-incoming@legolas.ozlabs.org","gcc-patches@gcc.gnu.org"],"Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (1024-bit key;\n unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256\n header.s=mimecast20190719 header.b=NB3lcYZ8;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org\n (client-ip=2620:52:6:3111::32; helo=vm01.sourceware.org;\n envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org;\n receiver=patchwork.ozlabs.org)","sourceware.org;\n\tdkim=pass (1024-bit key,\n unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256\n header.s=mimecast20190719 header.b=NB3lcYZ8","sourceware.org; dmarc=pass (p=quarantine dis=none)\n header.from=redhat.com","sourceware.org; spf=pass smtp.mailfrom=redhat.com","server2.sourceware.org;\n arc=none smtp.remote-ip=170.10.133.124"],"Received":["from vm01.sourceware.org (vm01.sourceware.org\n [IPv6:2620:52:6:3111::32])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fwqbq07M2z1yHc\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 16 Apr 2026 04:36:21 +1000 (AEST)","from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id 880674BA2E14\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 15 Apr 2026 18:36:19 +0000 (GMT)","from us-smtp-delivery-124.mimecast.com\n (us-smtp-delivery-124.mimecast.com [170.10.133.124])\n by sourceware.org (Postfix) with ESMTP id 860E94BA2E07\n for <gcc-patches@gcc.gnu.org>; Wed, 15 Apr 2026 18:35:51 +0000 (GMT)","from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com\n (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by\n relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3,\n cipher=TLS_AES_256_GCM_SHA384) id us-mta-696-Fmkta_FMO7aUCmvWV9hD7g-1; Wed,\n 15 Apr 2026 14:35:50 -0400","from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com\n (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93])\n (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest\n SHA256)\n (No client certificate requested)\n by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS\n id 2D7C719560A3\n for <gcc-patches@gcc.gnu.org>; Wed, 15 Apr 2026 18:35:49 +0000 (UTC)","from pdp-11.redhat.com (unknown [10.22.81.27])\n by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP\n id 8F1E018004AD; Wed, 15 Apr 2026 18:35:48 +0000 (UTC)"],"DKIM-Filter":["OpenDKIM Filter v2.11.0 sourceware.org 880674BA2E14","OpenDKIM Filter v2.11.0 sourceware.org 860E94BA2E07"],"DMARC-Filter":"OpenDMARC Filter v1.4.2 sourceware.org 860E94BA2E07","ARC-Filter":"OpenARC Filter v1.0.0 sourceware.org 860E94BA2E07","ARC-Seal":"i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1776278151; cv=none;\n b=XSO3oulgG9s/Y28eZKHYFAjhvZTgRUT6d/AcnYqTbttlhDyNXUeflRmlrEkDwVXtZ7DwT0l3XKFYefRSqsA4T+J9EPPvrVzgPsg/2sw1Nf8RnuJHYU4X8yzok85ZUSi6jUQ4ZEhP/tEWNoTFuE6w0oFfnJU1r4U/cbspx7E0R98=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1776278151; c=relaxed/simple;\n bh=OzYX52RWUT0gS2QSAxY1o/63StEGa1M95GZnRSlsx1A=;\n h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version;\n b=oadm59UTm9yTSLzK5HctKeIQzXMEwC2RdpWJYefgul49UwjWVLOeKEnN4fkGlFTLyOzChff2CGuXGBsq9TysIkPyvlwPHsMGz/cXnXxMn7RN3PjhkMZjCE/gIAd66Ix5gQGcCuvF70iiIjHd6pMkq71D5k3ZduaNTnujn1BqNmI=","ARC-Authentication-Results":"i=1; server2.sourceware.org","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1776278151;\n h=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n to:to:cc:mime-version:mime-version:content-type:content-type:\n content-transfer-encoding:content-transfer-encoding;\n bh=zsQk9iJT7DbYTlEjuNWI3lwTUxoP4NhhJgzA1GQgqNs=;\n b=NB3lcYZ8f4gQ7/yMnw+lpBwxsyQ3I41jdAab2e+U6dI/vM4jNaiM2zvgEEpzqHIqFPGbkA\n GiDNzLj+u12ykcMP27HKcL8UzxdBpKNs+t3Kxz4C/9m9YTJ3xAMvuHdBMHk4BGT4qYoPX5\n YFPJNRxxJgswCBoE8yjHqLlyS7H8FPQ=","X-MC-Unique":"Fmkta_FMO7aUCmvWV9hD7g-1","X-Mimecast-MFC-AGG-ID":"Fmkta_FMO7aUCmvWV9hD7g_1776278149","From":"Marek Polacek <polacek@redhat.com>","To":"GCC Patches <gcc-patches@gcc.gnu.org>, Jason Merrill <jason@redhat.com>,\n Patrick Palka <ppalka@redhat.com>","Subject":"[PATCH] c++: ICE with deleted main [PR120338]","Date":"Wed, 15 Apr 2026 14:35:39 -0400","Message-ID":"<20260415183539.1303758-1-polacek@redhat.com>","MIME-Version":"1.0","X-Scanned-By":"MIMEDefang 3.4.1 on 10.30.177.93","X-Mimecast-Spam-Score":"0","X-Mimecast-MFC-PROC-ID":"79AScBZ9G_ozKWHDYeyfTPtM9F_mhpsDBwS5V7hS9oQ_1776278149","X-Mimecast-Originator":"redhat.com","Content-Transfer-Encoding":"8bit","content-type":"text/plain; charset=\"US-ASCII\"; x-default=true","X-BeenThere":"gcc-patches@gcc.gnu.org","X-Mailman-Version":"2.1.30","Precedence":"list","List-Id":"Gcc-patches mailing list <gcc-patches.gcc.gnu.org>","List-Unsubscribe":"<https://gcc.gnu.org/mailman/options/gcc-patches>,\n <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe>","List-Archive":"<https://gcc.gnu.org/pipermail/gcc-patches/>","List-Post":"<mailto:gcc-patches@gcc.gnu.org>","List-Help":"<mailto:gcc-patches-request@gcc.gnu.org?subject=help>","List-Subscribe":"<https://gcc.gnu.org/mailman/listinfo/gcc-patches>,\n <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe>","Errors-To":"gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org"},"content":"Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk/15?\n\n-- >8 --\nHere we ICE with deleted main which is later redefined at\n\n  gcc_assert (DECL_SAVED_TREE (fn));\n\nbecause for some reason when deleting main I chose NULL_TREE instead of\nerror_mark_node as its DECL_INITIAL.  For other deleted functions we\nalso use error_mark_node so that\n\n  void foo() = delete;\n  void foo() {}\n\nresults in the \"redefinition of\" error.  Let's do the same for main, then.\n\n\tPR c++/120338\n\ngcc/cp/ChangeLog:\n\n\t* decl.cc (cp_finish_decl): Set DECL_INITIAL to error_mark_node\n\tinstead of NULL_TREE for deleted main.\n\ngcc/testsuite/ChangeLog:\n\n\t* g++.dg/cpp0x/deleted19.C: New test.\n---\n gcc/cp/decl.cc                         | 2 +-\n gcc/testsuite/g++.dg/cpp0x/deleted19.C | 5 +++++\n 2 files changed, 6 insertions(+), 1 deletion(-)\n create mode 100644 gcc/testsuite/g++.dg/cpp0x/deleted19.C\n\n\nbase-commit: 7cd246560ffcf0ffb9c64a4e9773011b74020e75","diff":"diff --git a/gcc/cp/decl.cc b/gcc/cp/decl.cc\nindex 7e40226d739..679a8007ca6 100644\n--- a/gcc/cp/decl.cc\n+++ b/gcc/cp/decl.cc\n@@ -9649,7 +9649,7 @@ cp_finish_decl (tree decl, tree init, bool init_const_expr_p,\n \t      /* [basic.start.main]/3: A program that defines main as deleted\n \t\t is ill-formed.  */\n \t      error (\"%<::main%> cannot be deleted\");\n-\t      DECL_INITIAL (decl) = NULL_TREE;\n+\t      DECL_INITIAL (decl) = error_mark_node;\n \t    }\n \t  else\n \t    {\ndiff --git a/gcc/testsuite/g++.dg/cpp0x/deleted19.C b/gcc/testsuite/g++.dg/cpp0x/deleted19.C\nnew file mode 100644\nindex 00000000000..c3f8f067748\n--- /dev/null\n+++ b/gcc/testsuite/g++.dg/cpp0x/deleted19.C\n@@ -0,0 +1,5 @@\n+// PR c++/120338\n+// { dg-do compile { target c++11 } }\n+\n+int main() = delete;  // { dg-error \"cannot be deleted\" }\n+int main() {}\t      // { dg-error \"redefinition\" }\n","prefixes":[]}