{"id":2218996,"url":"http://patchwork.ozlabs.org/api/patches/2218996/?format=json","web_url":"http://patchwork.ozlabs.org/project/gcc/patch/CAGkQGiKmQwMbBDBZpe-4+fHrZBUnPqgozd8s-wgpA+UQNZJH7A@mail.gmail.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":"<CAGkQGiKmQwMbBDBZpe-4+fHrZBUnPqgozd8s-wgpA+UQNZJH7A@mail.gmail.com>","list_archive_url":null,"date":"2026-04-02T09:36:31","name":"[fortran] PR100155 - [13/14/15/16 Regression] ICE in gfc_conv_intrinsic_size, at fortran/trans-intrinsic.c:805","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"50ec2e7d725a8f869927c214e6945c00d7cdc3b4","submitter":{"id":4392,"url":"http://patchwork.ozlabs.org/api/people/4392/?format=json","name":"Paul Richard Thomas","email":"paul.richard.thomas@gmail.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/gcc/patch/CAGkQGiKmQwMbBDBZpe-4+fHrZBUnPqgozd8s-wgpA+UQNZJH7A@mail.gmail.com/mbox/","series":[{"id":498457,"url":"http://patchwork.ozlabs.org/api/series/498457/?format=json","web_url":"http://patchwork.ozlabs.org/project/gcc/list/?series=498457","date":"2026-04-02T09:36:31","name":"[fortran] PR100155 - [13/14/15/16 Regression] ICE in gfc_conv_intrinsic_size, at fortran/trans-intrinsic.c:805","version":1,"mbox":"http://patchwork.ozlabs.org/series/498457/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2218996/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2218996/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 (2048-bit key;\n unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256\n header.s=20251104 header.b=UcBWq45L;\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 (2048-bit key,\n unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256\n header.s=20251104 header.b=UcBWq45L","sourceware.org;\n dmarc=pass (p=none dis=none) header.from=gmail.com","sourceware.org; spf=pass smtp.mailfrom=gmail.com","server2.sourceware.org;\n arc=pass smtp.remote-ip=74.125.82.48"],"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 4fmcFr61Gnz1yGH\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 02 Apr 2026 20:37:19 +1100 (AEDT)","from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id 58FA34BA2E38\n\tfor <incoming@patchwork.ozlabs.org>; Thu,  2 Apr 2026 09:37:17 +0000 (GMT)","from mail-dl1-f48.google.com (mail-dl1-f48.google.com\n [74.125.82.48])\n by sourceware.org (Postfix) with ESMTPS id C0BA44BA2E09\n for <gcc-patches@gcc.gnu.org>; Thu,  2 Apr 2026 09:36:44 +0000 (GMT)","by mail-dl1-f48.google.com with SMTP id\n a92af1059eb24-1279eced0b9so837404c88.0\n for <gcc-patches@gcc.gnu.org>; Thu, 02 Apr 2026 02:36:44 -0700 (PDT)"],"DKIM-Filter":["OpenDKIM Filter v2.11.0 sourceware.org 58FA34BA2E38","OpenDKIM Filter v2.11.0 sourceware.org C0BA44BA2E09"],"DMARC-Filter":"OpenDMARC Filter v1.4.2 sourceware.org C0BA44BA2E09","ARC-Filter":"OpenARC Filter v1.0.0 sourceware.org C0BA44BA2E09","ARC-Seal":["i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1775122605; cv=pass;\n b=esJq3i0TukSUjCg2iFj3XZVJTafyY2i/2YIlszWhufllw7D4UFDbTsWfrl3yv/tuTBzlcuyK6/hetGXey/pCmhFtTKRLNv9DjgmOgN2/m1R8qnVambmI8t6+YsaMHmRkNidIVFCNW/q7eWxSenrzzWChPki6VZlZ0k2Z224D3Xg=","i=1; a=rsa-sha256; t=1775122603; cv=none;\n d=google.com; s=arc-20240605;\n b=KQDStQ3iSnbuxkT6hzAkSv6Hh8qbVk2CpRA6H8OK7nppNttUsH8BJOqoi3FU7Tma8y\n lH0MH7UBGtfOSdp2384hSfN02D0ybZl+EvSIoPpiht3XaWPJ4mQwZAv2KqVgY0iqNKRU\n wSDCZQcQRYdxSVNYS18zdeKqwN7sQQddvCbV4MGogm4YQkUBb7OXa4xYJpIbT04EN2r1\n HV6irkWhP5mVz/ZZaAh6517Uz0nBsZRHVdZvVsRvaL1PgabS6bjMZQ2g+/E7mDTdmRrP\n mxU8edhgGqUSVm6Ln9J8TQuSIaZbqhEqeRA1K/hovDD/uNBgaE3as9ZQod43bmhcoFZJ\n 97XA=="],"ARC-Message-Signature":["i=2; a=rsa-sha256; d=sourceware.org; s=key;\n t=1775122605; c=relaxed/simple;\n bh=8mZSXVzayOv35fQOEcdwIz5ZmNm0dM5zZ3lOtAOpSf8=;\n h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To;\n b=kIOJSCO0rJP9i5UI2uKbXYkHUPdGC2szKb/UdT8RAqlj346DYjHeVQz751fIu8AZk8rNFWqWPZSfRePufEKNIT1+2phlHU4AyFRTFJcQFnQjqtAIRHhcXVnokQGyIlSP2X3iGI8fBzNPvcAcW4DOjTuFPAFORFXuJJatioNEv54=","i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com;\n s=arc-20240605;\n h=to:subject:message-id:date:from:mime-version:dkim-signature;\n bh=8mZSXVzayOv35fQOEcdwIz5ZmNm0dM5zZ3lOtAOpSf8=;\n fh=IrPR7rFrdFJtm8TsH0VmFZ5KfpgbXHxAS4c/ZXjUkhw=;\n b=RRS3d6+WufDYqcmDOs5+D0SGfh49nIWU5IAG3OYajgbH7BKlt5CeA6DVkv03W+2Bd/\n H2F5/s/BGDX8ef9ND8DYw/OnPfHkm2kyCHs0MiUYutjeHvKsFMAPytpBfGA+C0gdT7bG\n WsBpTOw4j5IflsG9Pi3AjAaNUHmc/ccm2IkSw6T2OHEPpp4aj1FRGNgY1lzeQR/DtEG7\n gU2OF6CRgW19701G+hiFOi93cqx1g8h2dsWloibcFItCL9zPfSrbPJCw1KQKmRxNVv9h\n Iay6uTlFVeRwVvupaKCUWrYVJf0Ct5JANntFFawtRz+CmHluTzQi0mu3RsYpK8/Lf9GJ\n MJUQ==; darn=gcc.gnu.org"],"ARC-Authentication-Results":["i=2; server2.sourceware.org","i=1; mx.google.com; arc=none"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=gmail.com; s=20251104; t=1775122603; x=1775727403; darn=gcc.gnu.org;\n h=to:subject:message-id:date:from:mime-version:from:to:cc:subject\n :date:message-id:reply-to;\n bh=8mZSXVzayOv35fQOEcdwIz5ZmNm0dM5zZ3lOtAOpSf8=;\n b=UcBWq45L9Q8yVDjA4GAz/PbGobjuwlWUnUiuvr5WoEhQAI6lrvgZrXputkPVrcWi8u\n bAjvtc7FaVbFbhuqAvb0gjevQndPhJVm2rgLrGZFKYoxQsFLYMrxTMLrY27yIUFXZFSL\n Qu9CLfZ1d++QNSXNL3Sx6PKVmOFnwOc1wxT9i5ouZJ7qP/qxNS+95E8lRQxtnw73EPLc\n adSUSi9iLcSxRy4WdbwBr+IyRT056XIvW3cIAOAffn034PQG5jM3T4MiCF+OV5UL1iqZ\n ErRk1ghVEPjaqDOXMchNinO459kAG2/R/c1aPBwW9i67N0HiOScNi0mXDeEkQbRskfcH\n nYtw==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1775122603; x=1775727403;\n h=to:subject:message-id:date:from:mime-version:x-gm-gg\n :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;\n bh=8mZSXVzayOv35fQOEcdwIz5ZmNm0dM5zZ3lOtAOpSf8=;\n b=FM2s48iOFAxlrKRD0GjBLrXtt8sbDlXBmlGlbLux38R5ezY4HmxARPq33C3mxWlWCV\n qwGz4ATHtNamKU/p/X/roCPr3CAEcSTlfR2xeusu51ib4v7OQcc14TPXPbla7WIn0qBB\n St0FE/s40oxIDXnhDtFWNbbECFMSgIKkb+9iVNX96vuffZ7lDJ4wLdWt+jt2NXK8Koqw\n 2BfcDifxCVXCQkJSphGvUYR+TpJEXx5w9biPgHNEfpk0fOfzUntpLkysgEug/ZHErlJz\n kjzTn7ELLsOvOACYN2fHxND7nUJgAKZUyqcH67J6xoiKEmRLc1QzyQIpl+lk4YJKRo1K\n SkWw==","X-Forwarded-Encrypted":"i=1;\n AJvYcCWkLsYMnRpOJNbFn/BpZ2U3EEBvqG5L6YSttNAFgqE4bb9O0GTNjPGDgIiRRFIb17C7xmffFTRXpWCaWA==@gcc.gnu.org","X-Gm-Message-State":"AOJu0Yydfbu3fxUA/5iGNU+UF5x1u9exB/Soswno77UOb9WiE2w5j6bS\n fVnZOf0KoV2Tn6aUXTmkmFTsL73xIQl0flH1GDXDkZNIVM0vlohwkAZd6AA2Y0LVsFxQJ6LLpQZ\n eTTpRgvziy/HaDaO7O+5xv9f4mXWRxak=","X-Gm-Gg":"ATEYQzwfjMya/7Zx39ebWOzqtixRG1QQkmN/uG4Q+aahjLE4oJ/bUE+Wb+gGAgI+sUt\n XmPhQA4+QjR12NKtOo4pKRUxiQioCxSs5TVzKRzas4un6jznxTh387I+MNC6GdfUKdoPLlTQS3o\n IQad2psbSHrgNRZk+zu/tK1arGQx3jJJNg56USlaSOSlOBFSjSjjrffSv1ByO3MorZYl4MxK4BF\n Ejhkd0gmT+6ZX99iakrpRF0FeDwuJgN8dWtKovZu/kdkAU44+eKaNm8ujgvcrqdnV33Om4BPqg6\n oELaqU7xgtTYYzdefNsGthsS4vVamV2Tz2fmholhAg==","X-Received":"by 2002:a05:7022:4a3:b0:119:e56b:91ec with SMTP id\n a92af1059eb24-12be64d641dmr3554589c88.29.1775122603419; Thu, 02 Apr 2026\n 02:36:43 -0700 (PDT)","MIME-Version":"1.0","From":"Paul Richard Thomas <paul.richard.thomas@gmail.com>","Date":"Thu, 2 Apr 2026 10:36:31 +0100","X-Gm-Features":"AQROBzBAbrtpIAZr7vRO2cs1Tuot1Xc8CSNILLdMXic78dZ6LTt_XYHwbIGy9JM","Message-ID":"\n <CAGkQGiKmQwMbBDBZpe-4+fHrZBUnPqgozd8s-wgpA+UQNZJH7A@mail.gmail.com>","Subject":"[Patch, fortran] PR100155 - [13/14/15/16 Regression] ICE in\n gfc_conv_intrinsic_size, at fortran/trans-intrinsic.c:805","To":"\"fortran@gcc.gnu.org\" <fortran@gcc.gnu.org>,\n gcc-patches <gcc-patches@gcc.gnu.org>","Content-Type":"multipart/mixed; boundary=\"000000000000362cd9064e76f040\"","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":"Hi All,\n\nThe attached fixes the PR and cures the memory leak in pr105168.\n\nRegtested on FC43/x86_64. OK for mainline and later backporting?\n\nPaul","diff":"From 3dc9212f1e7cca04b955853650c37b707554bafd Mon Sep 17 00:00:00 2001\nFrom: Paul Thomas <pault@gcc.gnu.org>\nDate: Thu, 2 Apr 2026 10:00:37 +0100\nSubject: [PATCH] Fortran: Regression in gfc_convert_to_structure_constructor\n\nThis patch is not the prettiest because it jumps across the normal\nwrapping up of the actual arguments in gfc_conv_procedure_call. However\nthe alternatives, which required jumps past existing call and the logic\nfor adding the pre and post blocks looked even uglier. The testcase has\nbeen checked with valgrind and does not cause memory leaks. The memory\nleaks in pr105168, mentioned in this pr, are fixed too.\n\n2026-04-02  Paul Thomas  <pault@gcc.gnu.org>\n\ngcc/fortran\n\tPR fortran/100155\n\t* trans-expr.cc (gfc_add_interface_mapping): 'new_sym' dummy\n\tattribute set to zero.\n\t(gfc_conv_procedure_call): Deallocate allocatable components of\n\ta class argument, enclosed in parentheses,wrap up the parmse\n\tand proceed to the next argument.\n\ngcc/testsuite/\n\tPR fortran/100155\n\t* gfortran.dg/pr100155.f90: New test.\n---\n gcc/fortran/trans-expr.cc              | 33 ++++++++++++++++++++\n gcc/testsuite/gfortran.dg/pr100155.f90 | 43 ++++++++++++++++++++++++++\n 2 files changed, 76 insertions(+)\n create mode 100644 gcc/testsuite/gfortran.dg/pr100155.f90\n\ndiff --git a/gcc/fortran/trans-expr.cc b/gcc/fortran/trans-expr.cc\nindex 52918961584..d6c580f8413 100644\n--- a/gcc/fortran/trans-expr.cc\n+++ b/gcc/fortran/trans-expr.cc\n@@ -5014,6 +5014,7 @@ gfc_add_interface_mapping (gfc_interface_mapping * mapping,\n   new_sym->attr.allocatable = sym->attr.allocatable;\n   new_sym->attr.flavor = sym->attr.flavor;\n   new_sym->attr.function = sym->attr.function;\n+  new_sym->attr.dummy = 0;\n \n   /* Ensure that the interface is available and that\n      descriptors are passed for array actual arguments.  */\n@@ -7835,6 +7836,38 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym,\n \t\t\t\t\t     : &parmse.pre;\n \t      gfc_add_block_to_block (class_pre_block, &class_se.pre);\n \t      gfc_add_block_to_block (&parmse.post, &class_se.post);\n+\n+\t      if (e->expr_type == EXPR_OP\n+\t\t  && POINTER_TYPE_P (TREE_TYPE (parmse.expr))\n+\t\t  && GFC_CLASS_TYPE_P (TREE_TYPE (TREE_OPERAND (parmse.expr, 0))))\n+\t\t{\n+\t\t  tree cond;\n+\t\t  tree dealloc_expr = gfc_finish_block (&parmse.post);\n+\t\t  tmp = TREE_OPERAND (parmse.expr, 0);\n+\t\t  gfc_init_block (&parmse.post);\n+\t\t  cond = gfc_class_data_get (tmp);\n+\t\t  tmp = gfc_deallocate_alloc_comp_no_caf (e->ts.u.derived,\n+\t\t\t\t\t\t\t  tmp, e->rank, true);\n+\t\t  gfc_add_expr_to_block (&parmse.post, tmp);\n+\t\t  cond = gfc_class_data_get (TREE_OPERAND (parmse.expr, 0));\n+\t\t  cond = gfc_conv_descriptor_data_get (cond);\n+\t\t  cond = fold_build2_loc (input_location, NE_EXPR,\n+\t\t\t\t\t  logical_type_node, cond,\n+\t\t\t\t\t  build_int_cst (TREE_TYPE (cond), 0));\n+\t\t  tmp = build3_v (COND_EXPR, cond, dealloc_expr,\n+\t\t\t\t  build_empty_stmt (input_location));\n+\n+\t\t  /* This specific case should not be processed further and so\n+\t\t     bundle everything up and proceed to the next argument.  */\n+\t\t  if (fsym && need_interface_mapping && e)\n+\t\t    gfc_add_interface_mapping (&mapping, fsym, &parmse, e);\n+\t\t  gfc_add_expr_to_block (&parmse.post, tmp);\n+\t\t  gfc_add_block_to_block (&se->pre, &parmse.pre);\n+\t\t  gfc_add_block_to_block (&post, &parmse.post);\n+\t\t  gfc_add_block_to_block (&se->finalblock, &parmse.finalblock);\n+\t\t  vec_safe_push (arglist, parmse.expr);\n+\t\t  continue;\n+\t\t}\n \t    }\n \t  else\n \t    {\ndiff --git a/gcc/testsuite/gfortran.dg/pr100155.f90 b/gcc/testsuite/gfortran.dg/pr100155.f90\nnew file mode 100644\nindex 00000000000..4a77963353d\n--- /dev/null\n+++ b/gcc/testsuite/gfortran.dg/pr100155.f90\n@@ -0,0 +1,43 @@\n+! { dg-do run }\n+! Test the fix for PR100155 in which the parentheses caused an ICE\n+! in evaluation the specification expression for 'z'. Note that the\n+! recursive attribute is not a factor in the ICE (see PR105168).\n+! Contributed by Gerhard Steinmetz  <gscfq@t-online.de>\n+!\n+module m1\n+   type t\n+     integer, allocatable :: i\n+   end type\n+   integer :: ctr = 0, vals = 0\n+   integer, parameter :: no_calls = 6\n+contains\n+   recursive function f(x) result(z)\n+      class(t) :: x(:)\n+      type(t) :: z(size(x)+1)\n+      class(t), allocatable :: a(:)\n+      type(t), allocatable :: b(:)\n+      ctr = ctr + 1\n+      allocate (t :: a(1))\n+      a(1)%i = ctr\n+      if (ctr <= no_calls - 1) then\n+          b = f((a)) ! <== parentheses\n+      else\n+          allocate (b(a(1)%i))\n+          b(1)%i = ctr\n+      end if\n+      vals = vals + b(1)%i\n+      z(1) = t(b(1)%i)\n+   end \n+end module m1\n+\n+  use m1\n+  type (t) :: dummy(1)\n+  type(t), allocatable :: res(:)\n+  dummy = t(1)\n+  res = f (dummy);\n+  if (ctr /= no_calls) stop 1\n+  if (vals /= (2 * sum ([(i, i = 1, no_calls)]) - no_calls)) stop 2\n+  if (size (res) /= 2) stop 3\n+  deallocate (res)\n+  deallocate (dummy(1)%i)\n+end\n-- \n2.53.0\n\n","prefixes":["fortran"]}