From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 33E7C3858D34 for ; Mon, 15 Apr 2024 07:38:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 33E7C3858D34 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 33E7C3858D34 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713166723; cv=none; b=u1hHUvwQiBwdJ7C8x9RRge1/lphY1bEvIZiDSWgTHKR6eYUiwGC092OXwRLuwM8UZ5+PSENCw5QwR08KdPXtBXLOXzkIHGa7EQgjQ/7Hr9KCo2pcdMlHZq7vjkMBX8mjDRy9Ho8MdylLtelp/jmx59cx3gZa/sf8sDbkuzcpXTc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713166723; c=relaxed/simple; bh=1BBKl8Q0RKX2LI5+CVkVvoXnWRff3GfBfCM8AFIsF9k=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=YAPKD8Fr5eU7yt9Qkokvi5zOm8YL+oY5StHw9/yUfBMidbJa4ln6kvY+9q02+D3endi2dNzxSHPw1tgq1jO/JpagR0q9lfiZGLpjKHBcJTHAKSpRbaiG9x93cEAQwUOnWp46X5aJOz+pru7PpqhwW91P/TiLsQ0JkyBtk9rp7Zc= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1713166721; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references; bh=Oo8TJHngagmaKcEGPsm82xvgq/k9K+lK385nSBmd0x8=; b=Q6zGLTfjO1T+eqtVoNgyCtrFbntg5G3MMKZvVHXvXfjgX2TmQax6eDKjuNzrp4Y221Zs3D 9JwVcYVi0eid0dtBcotFqGEqOZBMhOmjzhYLiYMZV21oRL0wvaF0RyDL5CVCOMY1wkFPHM Cb18toEmEWk+0g5XS3mkC9oF2pOsJGg= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-195-20-Cs2SeM7qOi4VMlgsXfg-1; Mon, 15 Apr 2024 03:38:36 -0400 X-MC-Unique: 20-Cs2SeM7qOi4VMlgsXfg-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1B6511C3F0E7; Mon, 15 Apr 2024 07:38:36 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.45.224.5]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9FDBB1121313; Mon, 15 Apr 2024 07:38:35 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 43F7cTN3049865 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Mon, 15 Apr 2024 09:38:30 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 43F7cTaN049864; Mon, 15 Apr 2024 09:38:29 +0200 Date: Mon, 15 Apr 2024 09:38:29 +0200 From: Jakub Jelinek To: Richard Biener Cc: Martin Uecker , gcc-patches@gcc.gnu.org, Joseph Myers Subject: Re: [C PATCH, v2] Fix ICE with -g and -std=c23 related to incomplete types [PR114361] Message-ID: Reply-To: Jakub Jelinek References: <02a9b94e4d653b6f1b9f89a1b62187f46e871738.camel@tugraz.at> <448b0744f89d5c6ba5d6a5bacda154fcb74b7bca.camel@tugraz.at> <71q844s1-p7ps-492r-qp8r-r8nq69s8qp8n@fhfr.qr> MIME-Version: 1.0 In-Reply-To: <71q844s1-p7ps-492r-qp8r-r8nq69s8qp8n@fhfr.qr> X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-10.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Mon, Apr 15, 2024 at 08:55:56AM +0200, Richard Biener wrote: > > diff --git a/gcc/ipa-free-lang-data.cc b/gcc/ipa-free-lang-data.cc > > index 16ed55e2e5a..6f75444e513 100644 > > --- a/gcc/ipa-free-lang-data.cc > > +++ b/gcc/ipa-free-lang-data.cc > > @@ -255,7 +255,9 @@ fld_incomplete_type_of (tree t, class free_lang_data_d *fld) > > first = build_reference_type_for_mode (t2, TYPE_MODE (t), > > TYPE_REF_CAN_ALIAS_ALL (t)); > > gcc_assert (TYPE_CANONICAL (t2) != t2 > > - && TYPE_CANONICAL (t2) == TYPE_CANONICAL (TREE_TYPE (t))); > > + && (TYPE_CANONICAL (t2) == TYPE_CANONICAL (TREE_TYPE (t)) > > + || TYPE_STRUCTURAL_EQUALITY_P (t2) > > + || TYPE_STRUCTURAL_EQUALITY_P (TREE_TYPE (t)))); > > I think we want the same canonical types for t2 and TREE_TYPE (t), why > doesn't fld_incomplete_type_of make it so? I had this spot instrumented to log the different cases (before adding the code to fix up also pointer types in c_update_type_canonical) and the only thing that triggered was that the 2 TYPE_CANONICALs weren't equal if TYPE_STRUCTURAL_EQUALITY_P (TREE_TYPE (t)), the other was just in case. gcc.c-torture/compile/20021205-1.c gcc.c-torture/compile/20040214-2.c gcc.c-torture/compile/20060109-1.c gcc.c-torture/compile/pr113623.c gcc.c-torture/compile/pr46866.c gcc.c-torture/compile/pta-1.c gcc.c-torture/execute/pr33870-1.c gcc.c-torture/execute/pr33870.c gcc.dg/torture/pr57478.c tests were affected in make check-gcc. I thought it would be a clear consequence of the choice we've discussed on IRC, that build_pointer_type_for_mode and other tree.cc functions which lookup/create derived types don't try to fill in TYPE_CANONICAL for types derived from something which initially had TYPE_STRUCTURAL_EQUALITY_P but later changed to non-TYPE_STRUCTURAL_EQUALITY_P. The patch updates it solely for qualified types/related pointer types, but doesn't do that for array types, pointer to array types, function types, ... So, I think the assertion could still trigger if we have something like -O2 -flto -std=c23 struct S; typedef struct S *T; typedef T U[10]; typedef U *V; V foo (int x) { return 0; } struct S { int s; }; (but doesn't, dunno what I'm missing; though here certainly V and U have TYPE_STRUCTURAL_EQUALITY_P, even T has because it is a typedef, not something actually normally returned by build_pointer_type). Jakub