Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/2196432/?format=api
{ "id": 2196432, "url": "http://patchwork.ozlabs.org/api/patches/2196432/?format=api", "web_url": "http://patchwork.ozlabs.org/project/gcc/patch/20260213220038.893789-1-albert@tugraz.at/", "project": { "id": 17, "url": "http://patchwork.ozlabs.org/api/projects/17/?format=api", "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": "<20260213220038.893789-1-albert@tugraz.at>", "list_archive_url": null, "date": "2026-02-13T22:00:38", "name": "fortran: Fix DO CONCURRENT nested-in-block iterator counting [PR123943]", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "c9b5121d7f906750daa7b0d4a8c5c440c3e52997", "submitter": { "id": 92019, "url": "http://patchwork.ozlabs.org/api/people/92019/?format=api", "name": "Christopher Albert", "email": "albert@tugraz.at" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/gcc/patch/20260213220038.893789-1-albert@tugraz.at/mbox/", "series": [ { "id": 492140, "url": "http://patchwork.ozlabs.org/api/series/492140/?format=api", "web_url": "http://patchwork.ozlabs.org/project/gcc/list/?series=492140", "date": "2026-02-13T22:00:38", "name": "fortran: Fix DO CONCURRENT nested-in-block iterator counting [PR123943]", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/492140/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2196432/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2196432/checks/", "tags": {}, "related": [], "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=tugraz.at header.i=@tugraz.at header.a=rsa-sha256\n header.s=mailrelay header.b=rak2fC6o;\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=tugraz.at header.i=@tugraz.at header.a=rsa-sha256\n header.s=mailrelay header.b=rak2fC6o", "sourceware.org; dmarc=pass (p=quarantine dis=none)\n header.from=tugraz.at", "sourceware.org; spf=pass smtp.mailfrom=tugraz.at", "server2.sourceware.org;\n arc=none smtp.remote-ip=129.27.2.202" ], "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 4fCR2h3VG7z1xr1\n\tfor <incoming@patchwork.ozlabs.org>; Sat, 14 Feb 2026 09:01:31 +1100 (AEDT)", "from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id 132F84BAD155\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 13 Feb 2026 22:01:29 +0000 (GMT)", "from mailrelay.tugraz.at (mailrelay.tugraz.at [129.27.2.202])\n by sourceware.org (Postfix) with ESMTPS id 5A4E54B9DB5B;\n Fri, 13 Feb 2026 22:00:51 +0000 (GMT)", "from mailuefterl.fritz.box (unknown [185.68.250.147])\n by mailrelay.tugraz.at (Postfix) with ESMTPSA id 4fCR1f503Pz2xML;\n Fri, 13 Feb 2026 23:00:38 +0100 (CET)" ], "DKIM-Filter": [ "OpenDKIM Filter v2.11.0 sourceware.org 132F84BAD155", "OpenDKIM Filter v2.11.0 sourceware.org 5A4E54B9DB5B" ], "DMARC-Filter": "OpenDMARC Filter v1.4.2 sourceware.org 5A4E54B9DB5B", "ARC-Filter": "OpenARC Filter v1.0.0 sourceware.org 5A4E54B9DB5B", "ARC-Seal": "i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1771020051; cv=none;\n b=j6v6By8N1IEFK1GeeOjtPnEQld1pXykYizQvjlooPUN0hX+/JQrwwtamhc/6iRtRqU8NTcrnhLzMg7+5NZ4/Pqy09fWgGCMZDPmCMuQSwCvGsIR6hBYeiNtj6kTp1d+Enr9uKLC/5Okba7wyYzH/INgatI4bX/GtBySWFYkQCv8=", "ARC-Message-Signature": "i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1771020051; c=relaxed/simple;\n bh=1Pybx8ZSu13TwjKHYQUdPia4z6fEcNJPWud29/C8da8=;\n h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version;\n b=Wa0nLs4Wnobymmpy/XMCaZAXF9NXKGsZi5wsYxgEM8y6DWKxMlGv6s/tPXoqvjvI1p/Hn+8hFS3bYM9u+0XkjzvCtl+2m/0PYQ31S13Fjp90Z9RAvSIgYBahMVAlFRDGRhypCOvgppaAmAmOSIRijb1xfZh90HXoSOsfOuJixNc=", "ARC-Authentication-Results": "i=1; server2.sourceware.org", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=tugraz.at;\n s=mailrelay; t=1771020038;\n bh=oXGS/QOfU639wZXhz99egsQILooGA9H6kHPuajY1Plg=;\n h=From:To:Cc:Subject:Date;\n b=rak2fC6oloyM9uC6HjcE+qk0WKNn4tJUPCEYGdRXmhffbwOnUCUIhrbIM/wikUIpH\n Q+2JsBV9cMgQz/hIth5qXFsqUQDnQMGzlzHAkMxxLeJRGrylPuiurQkQWDOWckArlv\n hTjMq0UG7BEqm8W/b9ZnMQRXa+TKAqE4xuLjEsDI=", "From": "Christopher Albert <albert@tugraz.at>", "To": "gcc-patches@gcc.gnu.org,\n\tfortran@gcc.gnu.org", "Cc": "anlauf@gcc.gnu.org, chr.albert@gmail.com, jvdelisle@gcc.gnu.org,\n Christopher Albert <albert@tugraz.at>", "Subject": "[PATCH] fortran: Fix DO CONCURRENT nested-in-block iterator counting\n [PR123943]", "Date": "Fri, 13 Feb 2026 23:00:38 +0100", "Message-ID": "<20260213220038.893789-1-albert@tugraz.at>", "X-Mailer": "git-send-email 2.53.0", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "X-TUG-Backscatter-control": "M8C9d6vb7ybI0LFLVdluXg", "X-Scanned-By": "MIMEDefang 2.74 on 129.27.10.116", "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": "Fix iterator-depth pre-counting in gfc_resolve_forall for nested\nDO CONCURRENT/FORALL constructs inside block arms (e.g. IF/ELSE,\nSELECT CASE). The previous logic only scanned a flat next-chain,\nwhich could undercount and trigger an ICE assertion.\n\nAdd a regression test based on a reduced testcase from Harald Anlauf.\nAdjust wording in one comment to avoid GNU-style checker complaints.\n\n\tPR fortran/123943\n\nCo-authored-by: Harald Anlauf <anlauf@gcc.gnu.org>\nSigned-off-by: Christopher Albert <albert@tugraz.at>\n---\n gcc/fortran/resolve.cc | 53 +++++++++++++++++---------\n gcc/testsuite/gfortran.dg/pr123943.f90 | 48 +++++++++++++++++++++++\n 2 files changed, 83 insertions(+), 18 deletions(-)\n create mode 100644 gcc/testsuite/gfortran.dg/pr123943.f90", "diff": "diff --git a/gcc/fortran/resolve.cc b/gcc/fortran/resolve.cc\nindex e5b36234d7e..d98c2d65476 100644\n--- a/gcc/fortran/resolve.cc\n+++ b/gcc/fortran/resolve.cc\n@@ -12433,33 +12433,50 @@ gfc_resolve_forall_body (gfc_code *code, int nvar, gfc_expr **var_expr)\n nested forall constructs. This is used to allocate the needed memory\n in gfc_resolve_forall. */\n \n+static int gfc_count_forall_iterators (gfc_code *code);\n+\n+/* Return the deepest nested FORALL/DO CONCURRENT iterator count in CODE's\n+ next-chain, descending into block arms such as IF/ELSE branches. */\n+\n+static int\n+gfc_max_forall_iterators_in_chain (gfc_code *code)\n+{\n+ int max_iters = 0;\n+\n+ for (gfc_code *c = code; c; c = c->next)\n+ {\n+ int sub_iters = 0;\n+\n+ if (c->op == EXEC_FORALL || c->op == EXEC_DO_CONCURRENT)\n+\tsub_iters = gfc_count_forall_iterators (c);\n+ else if (c->block)\n+\tfor (gfc_code *b = c->block; b; b = b->block)\n+\t {\n+\t int arm_iters = gfc_max_forall_iterators_in_chain (b->next);\n+\t if (arm_iters > sub_iters)\n+\t sub_iters = arm_iters;\n+\t }\n+\n+ if (sub_iters > max_iters)\n+\tmax_iters = sub_iters;\n+ }\n+\n+ return max_iters;\n+}\n+\n+\n static int\n gfc_count_forall_iterators (gfc_code *code)\n {\n- int max_iters, sub_iters, current_iters;\n+ int current_iters = 0;\n gfc_forall_iterator *fa;\n \n gcc_assert (code->op == EXEC_FORALL || code->op == EXEC_DO_CONCURRENT);\n- max_iters = 0;\n- current_iters = 0;\n \n for (fa = code->ext.concur.forall_iterator; fa; fa = fa->next)\n- current_iters ++;\n-\n- code = code->block->next;\n-\n- while (code)\n- {\n- if (code->op == EXEC_FORALL || code->op == EXEC_DO_CONCURRENT)\n- {\n- sub_iters = gfc_count_forall_iterators (code);\n- if (sub_iters > max_iters)\n- max_iters = sub_iters;\n- }\n- code = code->next;\n- }\n+ current_iters++;\n \n- return current_iters + max_iters;\n+ return current_iters + gfc_max_forall_iterators_in_chain (code->block->next);\n }\n \n \ndiff --git a/gcc/testsuite/gfortran.dg/pr123943.f90 b/gcc/testsuite/gfortran.dg/pr123943.f90\nnew file mode 100644\nindex 00000000000..6d6461317c2\n--- /dev/null\n+++ b/gcc/testsuite/gfortran.dg/pr123943.f90\n@@ -0,0 +1,48 @@\n+! { dg-do compile }\n+! PR fortran/123943\n+!\n+! Nested DO CONCURRENT in block constructs must not ICE in gfc_resolve_forall.\n+! Reduced testcase by Harald Anlauf <anlauf@gcc.gnu.org>\n+\n+subroutine nested_in_if\n+ implicit none\n+ integer :: k, l\n+\n+ do concurrent (k = 1:5)\n+ if (k == 3) then\n+ do concurrent (l = 1:4)\n+ end do\n+ end if\n+ end do\n+end subroutine nested_in_if\n+\n+\n+subroutine nested_in_if_else\n+ implicit none\n+ integer :: k, l\n+\n+ do concurrent (k = 1:5)\n+ if (k == 3) then\n+ do concurrent (l = 1:4)\n+ end do\n+ else\n+ do concurrent (l = 1:2)\n+ end do\n+ end if\n+ end do\n+end subroutine nested_in_if_else\n+\n+\n+subroutine nested_in_select_case\n+ implicit none\n+ integer :: k, l\n+\n+ do concurrent (k = 1:5)\n+ select case (k)\n+ case (3)\n+ do concurrent (l = 1:4)\n+ end do\n+ case default\n+ end select\n+ end do\n+end subroutine nested_in_select_case\n", "prefixes": [] }