{"id":2174158,"url":"http://patchwork.ozlabs.org/api/patches/2174158/?format=json","web_url":"http://patchwork.ozlabs.org/project/gcc/patch/5736333.rdbgypaU67@fomalhaut/","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":"<5736333.rdbgypaU67@fomalhaut>","list_archive_url":null,"date":"2025-12-15T08:20:49","name":"[Ada] Fix ICE in fld_incomplete_type_of when building GtkAda with LTO","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"feac665107e8fb94d842ed27dbb1a6b33812688a","submitter":{"id":78832,"url":"http://patchwork.ozlabs.org/api/people/78832/?format=json","name":"Eric Botcazou","email":"botcazou@adacore.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/gcc/patch/5736333.rdbgypaU67@fomalhaut/mbox/","series":[{"id":485361,"url":"http://patchwork.ozlabs.org/api/series/485361/?format=json","web_url":"http://patchwork.ozlabs.org/project/gcc/list/?series=485361","date":"2025-12-15T08:20:49","name":"[Ada] Fix ICE in fld_incomplete_type_of when building GtkAda with LTO","version":1,"mbox":"http://patchwork.ozlabs.org/series/485361/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2174158/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2174158/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 secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256\n header.s=google header.b=H4TEjNop;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org\n (client-ip=38.145.34.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 secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256\n header.s=google header.b=H4TEjNop","sourceware.org; dmarc=pass (p=quarantine dis=none)\n header.from=adacore.com","sourceware.org; spf=pass smtp.mailfrom=adacore.com","server2.sourceware.org;\n arc=none smtp.remote-ip=209.85.221.43"],"Received":["from vm01.sourceware.org (vm01.sourceware.org [38.145.34.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 4dVCh633jkz1y15\n\tfor <incoming@patchwork.ozlabs.org>; Mon, 15 Dec 2025 19:21:25 +1100 (AEDT)","from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id 45FA34BA2E07\n\tfor <incoming@patchwork.ozlabs.org>; Mon, 15 Dec 2025 08:21:23 +0000 (GMT)","from mail-wr1-f43.google.com (mail-wr1-f43.google.com\n [209.85.221.43])\n by sourceware.org (Postfix) with ESMTPS id C0B134BA2E25\n for <gcc-patches@gcc.gnu.org>; Mon, 15 Dec 2025 08:20:52 +0000 (GMT)","by mail-wr1-f43.google.com with SMTP id\n ffacd0b85a97d-42e33956e76so1455747f8f.3\n for <gcc-patches@gcc.gnu.org>; Mon, 15 Dec 2025 00:20:52 -0800 (PST)","from fomalhaut.localnet ([2a01:e0a:8d5:d990:e654:e8ff:fe8f:2ce6])\n by smtp.gmail.com with ESMTPSA id\n ffacd0b85a97d-42fa8b9b6bfsm27489570f8f.43.2025.12.15.00.20.50\n for <gcc-patches@gcc.gnu.org>\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Mon, 15 Dec 2025 00:20:50 -0800 (PST)"],"DKIM-Filter":["OpenDKIM Filter v2.11.0 sourceware.org 45FA34BA2E07","OpenDKIM Filter v2.11.0 sourceware.org C0B134BA2E25"],"DMARC-Filter":"OpenDMARC Filter v1.4.2 sourceware.org C0B134BA2E25","ARC-Filter":"OpenARC Filter v1.0.0 sourceware.org C0B134BA2E25","ARC-Seal":"i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1765786853; cv=none;\n b=clL3buREwU4xLA8aCE9EAq83l4XLpEjhh63TiDdZCsyvraG9TdGlq8CV+ABb8rX++RLv/lrPWPLX0h+JuE02nBH14jMRX++Fl2VOArwGOqFbqh9Sg4Oimzr/02MYOmJ259iIfJBZzOELD3b3egJTL1UZxfdg5cwZImMnr7KSEB4=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1765786853; c=relaxed/simple;\n bh=nk5xF401GIgwo0eBuQYCbXJsnc9nY7bIVyhr/MXvKwM=;\n h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version;\n b=o2iChLk2/ZFj0IRjtNo5jBmLS86riWJZvz27uieZwibhmUwffL03My21muOg4m2isZWvpNsXi11amdyxuFHu7rnG/6u5mT0SF8HzgW3St3oyJ/Mb7h3nBWJmX7NHQwRT89X5As4NH6xVaR0pAEGK9a1lIL0QN4msDB3icZKVlWM=","ARC-Authentication-Results":"i=1; server2.sourceware.org","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=adacore.com; s=google; t=1765786852; x=1766391652; darn=gcc.gnu.org;\n h=content-transfer-encoding:mime-version:message-id:date:subject:to\n :from:from:to:cc:subject:date:message-id:reply-to;\n bh=ZaHPwVJYTj0lomoKAhzH1NOAbQI/CgNBin5vYI1sCq4=;\n b=H4TEjNopqMvX2KCRhZFTFDn0xzWHJtjX/Ee8TqUH8zrfsh4fGZzkfmsZWCkoRcbNhf\n X2XF3hY0V9OVAoO0+FOgwfbYOLX8TlS3eyHh2K2h+/3swx8Qwdvcs00lBT2bhyPypxy0\n 99xoUJjN+prJxVX/3ki9zoeo0lTFJMZVX5E4gfy0MUyskRUl5MCpyVinot/a5Z6xkyW6\n 3dTb7Jo84avNJiWDqZbRuAeiRjqsUTT/CEvcPHBbekMDBylTzepArM+q5tmxwt3ioCWl\n Zr3zvgORvEOtu18odVyvw7Lw9pmVWONFxskE69f2Ch0M4i04rRMOtgUbbqGB2o8aOq1d\n 1D9Q==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20230601; t=1765786852; x=1766391652;\n h=content-transfer-encoding:mime-version:message-id:date:subject:to\n :from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id\n :reply-to;\n bh=ZaHPwVJYTj0lomoKAhzH1NOAbQI/CgNBin5vYI1sCq4=;\n b=ohYr9QIx5uoAP0FQKOyISPbbTy3SWIXFe7UxNt2p6+cSaAsjLhqvi6TBUAyEU99vuU\n MC0pX4G+vDXX214hQh3utdKOnJ9c7nT0iL9Qv4OKxlGPcabJ2AcysPVk4xmRa2YfIGDP\n OEMgo0cebqShGMez/+6C/TA0xsA2ZHmUf7Ql2gbd9hFGq87XhAhRxwbXgGbQVHPJDDcI\n kpt8mOWyZ2uiSVdrExc+adGiXcFMuxon/JTeaG7qaNxSjGST/tXXb4KQWpZO4TSudBRI\n oxflI7n9xctcnYQvkxnybsw7u5iSCvTh9/uMhrB3RiVXgH5nMZxQg4EWpRDHqLkf99uG\n Evmw==","X-Gm-Message-State":"AOJu0Ywpwv50MI3GkQEMrVIo6IHJPHzG1yg26d4El8+m3mDr/QAKJBHy\n vHxpWX8TgR6xKE+Dteqgylxc1nGStrJy2sKl3H9u1vkIWcu9Zf1tp6l43CGQJukrRXU9xUxxsIq\n Pcr8=","X-Gm-Gg":"AY/fxX61CtlZ+qmpGT5Mv0aJPLCDpeK6i5tLSZoXa+8TkUyzpMudwGJnpjI9hxPT/zO\n 7VlMiWjMxw9Y1l4znyRONHl+0JKD6C6nzITXHkz50ki74KDdNkgEQuNwTu4CR2U1O96Q6WO1Grg\n KINymfdTimpEmTANCIJU0v3D4fOCLyJUxJjqODlrlWQjiB63ut6irJ/4eSzUyuT2UPfIkU6GGba\n Yqc1UeWOKekKpTkoC100mpzXgvsOTFUfjayLi1EksENQlRosdQbpr/Ig9kYQC+w9wZ+R6RyjzxV\n 5uDxi9mYg7nh1yDAjDloaw1LT4AxAJ72aks4usCmkR3uHmE2ZqOJntR0Ott4U8J5y62Vhfv//dN\n N5nt0pcIB3X01GxkR9qxddXa9tdEEiitbsYPQMVqcKZ7Adf2nWqLPTtTXitvk8hqMFj9DWGBP64\n wNZJcUVIXBG6c/TlHRnlVk1FQ=","X-Google-Smtp-Source":"\n AGHT+IESO2wwWn4QyQRWKold8sexV25IAJF4TOtBGkFuCRfTXVUq8cJb30J4YyfsLG3ECiZXTy+ozA==","X-Received":"by 2002:a05:6000:288d:b0:431:26b:5e3f with SMTP id\n ffacd0b85a97d-431026b60f9mr131231f8f.63.1765786851561;\n Mon, 15 Dec 2025 00:20:51 -0800 (PST)","From":"Eric Botcazou <botcazou@adacore.com>","X-Google-Original-From":"Eric Botcazou <ebotcazou@adacore.com>","To":"gcc-patches@gcc.gnu.org","Subject":"[Ada] Fix ICE in fld_incomplete_type_of when building GtkAda with LTO","Date":"Mon, 15 Dec 2025 09:20:49 +0100","Message-ID":"<5736333.rdbgypaU67@fomalhaut>","MIME-Version":"1.0","Content-Type":"multipart/mixed; boundary=\"nextPart3563313.LZWGnKmheA\"","Content-Transfer-Encoding":"7Bit","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":"This is a regression from GCC 9 present on mainline and all active branches: \nthe compilation of GtkAda in LTO mode trips on the assertion present in the \nfld_incomplete_type_of function about the TYPE_CANONICAL of types pointed to \nby pointer (or reference) types.  The problem comes from an oversight in the \nupdate_pointer_to function on gcc-interface, which correctly propagates the \nTYPE_CANONICAL of the new pointer type to the old one when there is a new \npointer type, but fails to synthesize it when there is no new pointer type.\n\nTested on x86-64/Linux, applied on the mainline, 15 and 14 branches.\n\n\n2025-12-15  Eric Botcazou  <ebotcazou@adacore.com>\n\n\tPR ada/123060\n\t* gcc-interface/utils.cc (update_pointer_to): Synthesize a new\n\tTYPE_CANONICAL for the old pointer type in the case where there\n\tis no new pointer type.  Likewise for references.\n\n\n2025-12-15  Eric Botcazou  <ebotcazou@adacore.com>\n\n\t* gnat.dg/lto30.ads, gnat.dg/lto30.adb: New test.","diff":"diff --git a/gcc/ada/gcc-interface/utils.cc b/gcc/ada/gcc-interface/utils.cc\nindex db736a8d26d..62587cdb91d 100644\n--- a/gcc/ada/gcc-interface/utils.cc\n+++ b/gcc/ada/gcc-interface/utils.cc\n@@ -4673,8 +4673,23 @@ update_pointer_to (tree old_type, tree new_type)\n \t    new_ptr = TYPE_NEXT_PTR_TO (new_ptr);\n \t  TYPE_NEXT_PTR_TO (new_ptr) = old_ptr;\n \t}\n-      else\n-\tTYPE_POINTER_TO (new_type) = old_ptr;\n+      else if (old_ptr)\n+\t{\n+\t  TYPE_POINTER_TO (new_type) = old_ptr;\n+\n+\t  /* If there is no pointer pointing to NEW_TYPE yet, re-compute the\n+\t     TYPE_CANONICAL of the old pointer but pointing to NEW_TYPE, like\n+\t     build_pointer_type would have done for such a pointer, because we\n+\t     will propagate it in the adjustment loop below.  */\n+\t  if (TYPE_STRUCTURAL_EQUALITY_P (new_type))\n+\t    SET_TYPE_STRUCTURAL_EQUALITY (old_ptr);\n+\t  else if (TYPE_CANONICAL (new_type) != new_type\n+\t\t   || (TYPE_REF_CAN_ALIAS_ALL (old_ptr)\n+\t\t       && !lookup_attribute (\"may_alias\",\n+\t\t\t\t\t     TYPE_ATTRIBUTES (new_type))))\n+\t    TYPE_CANONICAL (old_ptr)\n+\t      = build_pointer_type (TYPE_CANONICAL (new_type));\n+\t}\n \n       /* Now adjust them.  */\n       for (ptr = old_ptr; ptr; ptr = TYPE_NEXT_PTR_TO (ptr))\n@@ -4694,8 +4709,23 @@ update_pointer_to (tree old_type, tree new_type)\n \t    new_ref = TYPE_NEXT_REF_TO (new_ref);\n \t  TYPE_NEXT_REF_TO (new_ref) = old_ref;\n \t}\n-      else\n-\tTYPE_REFERENCE_TO (new_type) = old_ref;\n+      else if (old_ref)\n+\t{\n+\t  TYPE_REFERENCE_TO (new_type) = old_ref;\n+\n+\t  /* If there is no reference pointing to NEW_TYPE yet, re-compute the\n+\t     TYPE_CANONICAL of the old reference but pointing to NEW_TYPE, like\n+\t     build_reference_type would have done for such a reference, because\n+\t     we will propagate it in the adjustment loop below.  */\n+\t  if (TYPE_STRUCTURAL_EQUALITY_P (new_type))\n+\t    SET_TYPE_STRUCTURAL_EQUALITY (old_ref);\n+\t  else if (TYPE_CANONICAL (new_type) != new_type\n+\t\t   || (TYPE_REF_CAN_ALIAS_ALL (old_ref)\n+\t\t       && !lookup_attribute (\"may_alias\",\n+\t\t\t\t\t     TYPE_ATTRIBUTES (new_type))))\n+\t    TYPE_CANONICAL (old_ref)\n+\t      = build_reference_type (TYPE_CANONICAL (new_type));\n+\t}\n \n       /* Now adjust them.  */\n       for (ref = old_ref; ref; ref = TYPE_NEXT_REF_TO (ref))\n","prefixes":["Ada"]}