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.133.124]) by sourceware.org (Postfix) with ESMTPS id 323FE386C5AB for ; Wed, 22 May 2024 13:38:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 323FE386C5AB 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 323FE386C5AB Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1716385140; cv=none; b=MCdJ5Rm/pb2d8jpfgPyiHLVLV0NoqFyl+mQikpCsaCSyn2p+72UDLffGRvUoN9Zh65sH3NLyVbNWyDprWqU4faAN2r0+TK7uGQ/c5bqgjyFk1uiPqxAja3Ixy004QjTpjaGWdcAtUWBp/zqisrxT/ReR2aizV/g371Rf8h06C20= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1716385140; c=relaxed/simple; bh=f6pZfnQFpHFS/7Kpo439qSJB4UuAfTV2IHQgpG4TRzY=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=kg2bZdRuBo1cpN79m38BeBMnOWfymtvVTLfuHlN1TT07PD86TQILO49dZfKgYpimQCkhp5joMs3Z0DP8bHFdvRIjdSBJ+oZcZ0u/V/97kYt4C1A1XJ3b/6CEW+FOjoItBaiSQouVwKTZpqmaGDPBpq+/HeSwCYRSgHXB+j00LEM= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1716385136; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3vLzEpxVmz6w7IHhNGmGo0tWQEf3wm6iwvQUQlSanjU=; b=a3Fn6mxsjrp2oR5HKzMJ01sZLUP2ETWl9vSClcsiFSsqF/PjqJTeO4p9PUOf3JXKZPoAfF R4ySY8Ubg9M6XgbEhRwHSaWKZ7ytyPlauNkEcFwUK5cY7b2Li7HuDt9ffFojXKeZAUAiC3 pIQRHb8X+Tp6pnhew/8Wbmu58QVGpxQ= Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-462-8KvXl-jtOyGvBxE-Ekc4ag-1; Wed, 22 May 2024 09:38:55 -0400 X-MC-Unique: 8KvXl-jtOyGvBxE-Ekc4ag-1 Received: by mail-qt1-f197.google.com with SMTP id d75a77b69052e-43d7cfc45abso173402051cf.0 for ; Wed, 22 May 2024 06:38:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716385134; x=1716989934; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=3vLzEpxVmz6w7IHhNGmGo0tWQEf3wm6iwvQUQlSanjU=; b=cY+Wn8l7yedX9RVOZHlJtysBMNX2SXkCDUcws9ikqWj68OL2nqOrssYSIIm4FRKjG4 dsQd+MOXaGyBQvzj9i6nlG3DvdQC6VSrEAelvP80Bu//tLexC5f77RbwiLMqPfcTogF5 onoitcQSWeq9wlB1aaYhYRVHJjB1jvykMemSU4KxMgma/CJmKOHl21oxZf1RgevXt+2E 67IQ/NSgonMoesXVttjKge59sdgI5ACPZWa/3e4tLQJ9na7cO1Vx9DYdD3oNQFkh19Ll rwAzwg6pooqWmK7wZXRLJfYu4KwNv3MmvuLKNBqk50RvSzXj/6U8Rg0cJh+GDDvEZ1An 0JoQ== X-Gm-Message-State: AOJu0YwPSgO1FemGK/oBTlMcebfcLzH3wDLxMOAS2Ch5ZTrDQoZOEXMU tikJUdwy5ZMvHcVGxDuhy+Aa2oE2hD34KraArXeTIY/NV5pslena/Ep0qXMViqarfN6Zv3jvSqr zrlWBphzsb0SJ7b1apymwsNxvgwSWwtdSQXIlIoiGUwjgLu0k9rsbBt6fuQKGqUg= X-Received: by 2002:ac8:7d8e:0:b0:43b:4d2:48cc with SMTP id d75a77b69052e-43f9e1ab377mr24159471cf.46.1716385134478; Wed, 22 May 2024 06:38:54 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGrP9IjuT77px4Yq4WGjj6BYNmuEJP7V0PxyrK/EQ/2Q96q2hTG54lGSUn+c8YtUt3Op6CtlQ== X-Received: by 2002:ac8:7d8e:0:b0:43b:4d2:48cc with SMTP id d75a77b69052e-43f9e1ab377mr24159191cf.46.1716385134077; Wed, 22 May 2024 06:38:54 -0700 (PDT) Received: from [192.168.1.130] (130-44-146-16.s12558.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [130.44.146.16]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-43df56e25eesm169793861cf.94.2024.05.22.06.38.53 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 22 May 2024 06:38:53 -0700 (PDT) Message-ID: <7a6b4271-d778-4734-af90-8e599f43dead@redhat.com> Date: Wed, 22 May 2024 09:38:52 -0400 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] c++: canonicity of fn types w/ complex eh specs [PR115159] To: Patrick Palka Cc: gcc-patches@gcc.gnu.org References: <20240521193629.4129787-1-ppalka@redhat.com> <42726cf3-3bf8-499a-b455-d0181f0b8d3b@redhat.com> <3356d9ff-9c60-a215-427c-9deaf6fb5024@idea> <9c0b3ede-9457-aa5c-0934-b82f7a44291f@idea> <8025f5c2-55b3-0eb9-288a-97e22e94b30b@idea> From: Jason Merrill In-Reply-To: <8025f5c2-55b3-0eb9-288a-97e22e94b30b@idea> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 5/22/24 09:01, Patrick Palka wrote: > On Tue, 21 May 2024, Jason Merrill wrote: > >> On 5/21/24 21:55, Patrick Palka wrote: >>> On Tue, 21 May 2024, Jason Merrill wrote: >>> >>>> On 5/21/24 17:27, Patrick Palka wrote: >>>>> On Tue, 21 May 2024, Jason Merrill wrote: >>>>> >>>>>> On 5/21/24 15:36, Patrick Palka wrote: >>>>>>> Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look >>>>>>> OK for trunk? >>>>>>> >>>>>>> Alternatively, I considered fixing this by incrementing >>>>>>> comparing_specializations around the call to comp_except_specs in >>>>>>> cp_check_qualified_type, but generally for types whose identity >>>>>>> depends on whether comparing_specializations is set we need to >>>>>>> use structural equality anyway IIUC. >>>>>> >>>>>> Why not both? >>>>> >>>>> I figured the latter change isn't necessary/observable since >>>>> comparing_specializations would only make a difference for complex >>>>> exception specifications, and with this patch we won't even call >>>>> cp_check_qualified_type on a complex eh spec. >>>> >>>> My concern is that if we're building a function type multiple times with >>>> the >>>> same noexcept-spec, this patch would mean creating multiple equivalent >>>> function types instead of reusing one already created for the same >>>> function. >>>> >>>>>>> + bool complex_p = (cr && cr != noexcept_true_spec >>>>>>> + && !UNPARSED_NOEXCEPT_SPEC_P (cr)); >>>>>> >>>>>> Why treat unparsed specs differently from parsed ones? >>>>> >>>>> Unparsed specs are unique according to cp_tree_equal, so in turn >>>>> function types with unparsed specs are unique, so it should be safe to >>>>> treat such types as canonical. I'm not sure if this optimization >>>>> matters though; I'm happy to remove this case. >>>> >>>> The idea that this optimization could make a difference raised the concern >>>> above. >>> >>> Aha, makes sense. To that end it seems we could strengthen the ce_exact >>> in comp_except_specs to require == instead of cp_tree_equal equality >>> when comparing two noexcept-specs; the only ce_exact callers are >>> cp_check_qualified_type and cxx_type_hash_eq, which should be fine with >>> that strengthening. This way, we at least do try to reuse a variant if >>> the (complex or unparsed) noexcept-spec is exactly the same. >> >> Sounds good. >> >> Given that, we probably still want to move the canonical_eh_spec up in >> build_cp_fntype_variant, and pass that to cp_check_qualified_type? > > And compare the canonical spec directly from cp_check_qualified_type > instead of using comp_except_specs? Then IIUC for > > void f() throw(int); > void g() throw(char); > > we'd give g the same function type as f, which seems wrong? Good point, I was confused about what canonical_eh_spec was doing. Your last patch is OK. Jason