{"id":2233240,"url":"http://patchwork.ozlabs.org/api/1.1/patches/2233240/?format=json","web_url":"http://patchwork.ozlabs.org/project/gcc/patch/20260505220106.163888-1-ibuclaw@gdcproject.org/","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":"<20260505220106.163888-1-ibuclaw@gdcproject.org>","date":"2026-05-05T22:01:06","name":"[committed] d: internal compiler error: in convert_move, at expr.cc:227","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"ac70243c70421197d3e29e5e21e2cc0e534b27b8","submitter":{"id":46728,"url":"http://patchwork.ozlabs.org/api/1.1/people/46728/?format=json","name":"Iain Buclaw","email":"ibuclaw@gdcproject.org"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/gcc/patch/20260505220106.163888-1-ibuclaw@gdcproject.org/mbox/","series":[{"id":502903,"url":"http://patchwork.ozlabs.org/api/1.1/series/502903/?format=json","web_url":"http://patchwork.ozlabs.org/project/gcc/list/?series=502903","date":"2026-05-05T22:01:06","name":"[committed] d: internal compiler error: in convert_move, at expr.cc:227","version":1,"mbox":"http://patchwork.ozlabs.org/series/502903/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2233240/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2233240/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 (2048-bit key;\n unprotected) header.d=gdcproject.org header.i=@gdcproject.org\n header.a=rsa-sha256 header.s=MBO0001 header.b=xDUFX7i6;\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=gdcproject.org header.i=@gdcproject.org\n header.a=rsa-sha256 header.s=MBO0001 header.b=xDUFX7i6","sourceware.org; dmarc=pass (p=quarantine dis=none)\n header.from=gdcproject.org","sourceware.org; spf=pass smtp.mailfrom=gdcproject.org","server2.sourceware.org;\n arc=none smtp.remote-ip=80.241.56.151","outgoing_mbo_mout; dkim=none;\n spf=pass (outgoing_mbo_mout: domain of ibuclaw@gdcproject.org designates\n 2001:67c:2050:b231:465::1 as permitted sender)\n smtp.mailfrom=ibuclaw@gdcproject.org"],"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 4g9D3X43qwz1yJV\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 06 May 2026 08:39:51 +1000 (AEST)","from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id 3AC524BA23C8\n\tfor <incoming@patchwork.ozlabs.org>; Tue,  5 May 2026 22:39:49 +0000 (GMT)","from mout-p-101.mailbox.org (mout-p-101.mailbox.org [80.241.56.151])\n by sourceware.org (Postfix) with ESMTPS id 98D7B4BA2E15\n for <gcc-patches@gcc.gnu.org>; Tue,  5 May 2026 22:39:12 +0000 (GMT)","from smtp1.mailbox.org (smtp1.mailbox.org\n [IPv6:2001:67c:2050:b231:465::1])\n (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest\n SHA256)\n (No client certificate requested)\n by mout-p-101.mailbox.org (Postfix) with ESMTPS id 4g9CBt3Dkdz9vLL;\n Wed,  6 May 2026 00:01:10 +0200 (CEST)"],"DKIM-Filter":["OpenDKIM Filter v2.11.0 sourceware.org 3AC524BA23C8","OpenDKIM Filter v2.11.0 sourceware.org 98D7B4BA2E15"],"DMARC-Filter":"OpenDMARC Filter v1.4.2 sourceware.org 98D7B4BA2E15","ARC-Filter":"OpenARC Filter v1.0.0 sourceware.org 98D7B4BA2E15","ARC-Seal":"i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1778020752; cv=none;\n b=XNVlVZAt3Y7S7APE5EBXymvHcx0BCt3WosiRXjqvOkpoZiW+SvFoQW1H/rcin3lGlBkPQgHerPlaLNlnVANYy40cu3uwfOxbFJrRPswkNCICIPgNGUANUDjmsL9+Sixyjx4NOaXd/ZVcJXY74/g0C9wPqJKZaG2CJEFgg5tFhXc=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1778020752; c=relaxed/simple;\n bh=FC698WfL7c5O3zvVf+wWkyrBl3cva8sPNrN+D2ecsW8=;\n h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version;\n b=C5iYvTf3TMMOJUzU5y8p3Gf2NENXCxtAVYHXic5FwG03HJs6WdwJF5f0Upv1QX6Jxa0zh12cINsSlgVnNemh5fR26Gy0MdAfUJyLARo0nrFj/gwDIKHsvDQRXqKAoUDeusHL8cg9Aw+eFY47GSCBlqpowH8YWiNAZiZUSG1TdVM=","ARC-Authentication-Results":"i=1; server2.sourceware.org","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=gdcproject.org;\n s=MBO0001; t=1778018470;\n h=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n to:to:cc:cc:mime-version:mime-version:\n content-transfer-encoding:content-transfer-encoding;\n bh=hKyG/al6UgVAAcc2nrZEgawgQdseHKMq0GsD6nj10bs=;\n b=xDUFX7i6DqeNmic0atH6Ccl1uoJzTgYsG3armrNpyZA0c4YDVi+8imKzmPJmFnkqM4O4NV\n 6RKjQS5h7Gwh94fvzIALDR1H28yZmpl3bnTFTiOiGI7qeRXGqe9LhDN0gOwVpRNXbS72PN\n Gv/V++zDsTQZucf/DDQN0aVkbIhSzBAzVLC0r5tzlvQE6g8pBQJtLDL/6rdFEmKSuwf7n4\n GHIX3Osa9mIJu6hpGyvvNe8bW4ObWJRhMj/u8F8EwNl5zwHvFgCD5eNVxyjOwgveXy/nLZ\n aubWgtEL/oE1gAbWgsl3aiL9rKo3VCDEHS64LL1SEWuSQSX3smj6rO3+y6AmUQ==","From":"Iain Buclaw <ibuclaw@gdcproject.org>","To":"gcc-patches@gcc.gnu.org","Cc":"Iain Buclaw <ibuclaw@gdcproject.org>","Subject":"[committed][PATCH] d: internal compiler error: in convert_move,\n at expr.cc:227","Date":"Wed,  6 May 2026 00:01:06 +0200","Message-ID":"<20260505220106.163888-1-ibuclaw@gdcproject.org>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","X-Rspamd-Queue-Id":"4g9CBt3Dkdz9vLL","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,\n\nThis patch fixes an ICE in the D2 compiler in convert_move.\n\nThis was caused by a forward reference of a nested struct changing the\nTYPE_MODE of its enclosing struct type to be incorrectly inferred as an\ninteger mode.  Fixed by setting TREE_ADDRESSABLE early, and moving the\nmode setting and propagation to finish_aggregate_mode and\nfinish_aggregate_type respectively, rather than at the end of the\nvisitor method for TypeStruct.\n\nBootstrapped and regtested on x86_64-linux-gnu, committed to mainline,\nand backported to gcc-13, gcc-14, gcc-15, and gcc-16 release branches.\n\nRegards,\nIain\n\n---\n\tPR d/125089\n\ngcc/d/ChangeLog:\n\n\t* types.cc (finish_aggregate_mode): Explicitly set TYPE_MODE of\n\tnon-POD types here.\n\t(finish_aggregate_type): Propagate TREE_ADDRESSABLE to all variants.\n\t(TypeVisitor::visit (TypeStruct *)): Set TREE_ADDRESSABLE before\n\tvisiting struct members.\n\ngcc/testsuite/ChangeLog:\n\n\t* gdc.dg/pr125089.d: New test.\n---\n gcc/d/types.cc                  | 26 +++++++++++++-------------\n gcc/testsuite/gdc.dg/pr125089.d | 20 ++++++++++++++++++++\n 2 files changed, 33 insertions(+), 13 deletions(-)\n create mode 100644 gcc/testsuite/gdc.dg/pr125089.d","diff":"diff --git a/gcc/d/types.cc b/gcc/d/types.cc\nindex b5658b6e8f4..d79a8972b5c 100644\n--- a/gcc/d/types.cc\n+++ b/gcc/d/types.cc\n@@ -593,7 +593,12 @@ finish_aggregate_mode (tree type)\n \treturn;\n     }\n \n-  compute_record_mode (type);\n+  /* Force mode of non-trivially copyable structs to be BLKmode, preventing it\n+     from being returned in a register.  */\n+  if (TREE_ADDRESSABLE (type))\n+    SET_TYPE_MODE (type, BLKmode);\n+  else\n+    compute_record_mode (type);\n \n   /* Propagate computed mode to all variants of this aggregate type.  */\n   for (tree t = TYPE_MAIN_VARIANT (type); t; t = TYPE_NEXT_VARIANT (t))\n@@ -715,6 +720,7 @@ finish_aggregate_type (unsigned structsize, unsigned alignsize, tree type)\n       TYPE_PACKED (t) = TYPE_PACKED (type);\n       SET_TYPE_ALIGN (t, TYPE_ALIGN (type));\n       TYPE_USER_ALIGN (t) = TYPE_USER_ALIGN (type);\n+      TREE_ADDRESSABLE (t) = TREE_ADDRESSABLE (type);\n     }\n \n   /* Complete any other forward-referenced fields of this aggregate type.  */\n@@ -1236,6 +1242,12 @@ public:\n     TYPE_LANG_SPECIFIC (t->ctype) = build_lang_type (t);\n     TYPE_CXX_ODR_P (t->ctype) = 1;\n \n+    /* For structs with a user defined postblit, copy constructor, or a\n+       destructor, also set TREE_ADDRESSABLE on the type and all variants.\n+       This will make the struct be passed around by reference.  */\n+    if (!dmd::isPOD (t->sym))\n+      TREE_ADDRESSABLE (t->ctype) = 1;\n+\n     if (t->sym->members)\n       {\n \t/* Must set up the overall size and alignment before determining\n@@ -1257,18 +1269,6 @@ public:\n \tbuild_type_decl (t->ctype, t->sym);\n \tapply_user_attributes (t->sym, t->ctype);\n       }\n-\n-    /* For structs with a user defined postblit, copy constructor, or a\n-       destructor, also set TREE_ADDRESSABLE on the type and all variants.\n-       This will make the struct be passed around by reference.  */\n-    if (!dmd::isPOD (t->sym))\n-      {\n-\tfor (tree tv = t->ctype; tv != NULL_TREE; tv = TYPE_NEXT_VARIANT (tv))\n-\t  {\n-\t    TREE_ADDRESSABLE (tv) = 1;\n-\t    SET_TYPE_MODE (tv, BLKmode);\n-\t  }\n-      }\n   }\n \n   /* Build a class type.  Whereas structs are value types, classes are\ndiff --git a/gcc/testsuite/gdc.dg/pr125089.d b/gcc/testsuite/gdc.dg/pr125089.d\nnew file mode 100644\nindex 00000000000..6936cf6e949\n--- /dev/null\n+++ b/gcc/testsuite/gdc.dg/pr125089.d\n@@ -0,0 +1,20 @@\n+// { dg-do compile }\n+struct R125089\n+{\n+    S125089.T st;\n+}\n+\n+struct S125089\n+{\n+    struct T\n+    {\n+        void* v;\n+        ~this() {}\n+    }\n+\n+    T t;\n+    this(R125089 r)\n+    {\n+        this.t = r.st;\n+    }\n+}\n","prefixes":["committed"]}