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 C990E38582BE for ; Sat, 2 Dec 2023 15:02:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C990E38582BE 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 C990E38582BE 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=1701529368; cv=none; b=NacpOLWczGbFaOF1fdXxZAa8jhJ0tVyoOLu0EiqAdlMSRbn1HcgwUnwMLgdJNEmu/UZucfl2LNExOeapYk7a2NyxPoLMqSb8HNbTZoFmG4Ei7PqK6j3F2KimQarrTUrsUnYetfFo9wEDFniMpdbUsOWWI8855WMozeAf6HFiaJ8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701529368; c=relaxed/simple; bh=Zk3YGxPOP8tuBOCEfaMp7J+TsPGc0dfq3L5y5UAN2QA=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=klVOWPrQ7f1cwcxp5gBhe/PpuHfRlReOT0IU3n18u2XcFykTsTBraJ6KM7vB/cAESr8ZipaxO/H0xkwhdOoLm9jjJh57/Zm8ViXVKEtzQtlLUrewkiA12AumBS0DIfHdiZ1wU8I4d4kLFQC8xTTvdqrHsE1K1G3XOLEZoPKRMzY= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1701529366; 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=Z8f07D7WehEca52wSbSCgTNHwRnOBfcpMctWHvmGP5I=; b=AM8Eb8DwT8XzFSu+1W4EaScYvYVEydsv1uxhRpKXcsftOHBNzcBQfOKkiAPpxrSNrMx/S1 Khw1iy/Rp4Kzli7mbHwnuWRYz+GPM67K0H2zNEUmg6LQbgPZaI1THwdqwGxvMlUIcIBpAF Y0aNZBwc3oq80dJCVA0k2JFbz+Simj4= Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-368-aAZ4LHj_PTuE8o3ScmO6-Q-1; Sat, 02 Dec 2023 10:02:45 -0500 X-MC-Unique: aAZ4LHj_PTuE8o3ScmO6-Q-1 Received: by mail-qv1-f72.google.com with SMTP id 6a1803df08f44-67a4bb77f47so61669796d6.0 for ; Sat, 02 Dec 2023 07:02:44 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701529364; x=1702134164; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Z8f07D7WehEca52wSbSCgTNHwRnOBfcpMctWHvmGP5I=; b=kYnpr+boXvuPMXFH9VmcOLrZfx24mhW7RHOaEvYm33BOJJSnxlm88lEk7B6F3AsDSS vGiC01xIwztvzlssXRLIoO+I+XXh1YIzCMzP6Av9m7vWx74KnE8Of+jbMBFvTbcB6DZF vKXjWFzoU18jpI32BZnHPVY6WBnmLIeAjCD/KxJNSYcrDm42pN6oncXlri130FKrLcOW Q2Vj5HiOtIcHIqlwHUQ+hDRmiepgdbuibm0nL1IDL8vDvaM9StwqzdtgclqbuCoLb+Z+ 5nhHspcM3L7AMOsVZmjK5/+uEaBC6lKn6ri1oVlykY0QsULFQV+RMXEbCErtYDiF+qVG +npw== X-Gm-Message-State: AOJu0Yx/hpXCG4m7vZCz4K0A4eaKVzPtOVO8T/Z6A/cdNlL61GpxV87O tdsgR5u6nA18+PwDF45ul16LUiCjHKy1+k22t5idUTU1/dWn8nwaNEtAlOW4aHAmqaz9lHpijKy 1Fpt8y5OAM5dmq7eCng== X-Received: by 2002:a05:6214:5006:b0:67a:5f26:7017 with SMTP id jo6-20020a056214500600b0067a5f267017mr1769223qvb.9.1701529364071; Sat, 02 Dec 2023 07:02:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IGXTNS5gMYOC0utNwf0TXvvsS6bMajixngXabi85vqNDwXE2Nxl1/qhdVHzfNkP5+zTBxScHQ== X-Received: by 2002:a05:6214:5006:b0:67a:5f26:7017 with SMTP id jo6-20020a056214500600b0067a5f267017mr1769209qvb.9.1701529363755; Sat, 02 Dec 2023 07:02:43 -0800 (PST) Received: from [192.168.1.145] (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 ow15-20020a05620a820f00b0077db614cb7fsm2490563qkn.8.2023.12.02.07.02.42 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 02 Dec 2023 07:02:42 -0800 (PST) Message-ID: <575c0bbe-a3d6-4a54-b299-edff64df84b1@redhat.com> Date: Sat, 2 Dec 2023 10:02:42 -0500 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v6 1/1] c++: Initial support for P0847R7 (Deducing This) [PR102609] To: waffl3x Cc: "gcc-patches@gcc.gnu.org" References: <-SP7aKgN1FZED-RAPr2FBDuCrcwnu9-UhHcRXNEsNZRwIzJXCdhVbtBP921Yn8g71d0WL7XpFRetUlBAStzRpZB8p4yj5moRS0DIE9D6cnY=@protonmail.com> <7623e2db-ba29-42f2-85df-c2e796d7305b@redhat.com> <_e1O52EjoN_BFiH31iHE-0eYegNJhoOdDN2O0mduqtMmt7qTGpRWgduxNppnO1si01rORJ470oWcoM-_lk1ICFo9lhe_ylBKQsJ791qMm_k=@protonmail.com> <1b3b0259-5ce4-4193-a36d-60f09e1c7c92@redhat.com> From: Jason Merrill In-Reply-To: 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.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,KAM_SHORT,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE 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 12/1/23 20:31, waffl3x wrote: > On Friday, December 1st, 2023 at 9:52 AM, Jason Merrill wrote: >> On 12/1/23 01:02, waffl3x wrote: >> >>> I ran into another issue while devising tests for redeclarations of >>> xobj member functions as static member functions and vice versa. I am >>> pretty sure by the literal wording of the standard, this is well formed. >>> >>> template >>> concept Constrain = true; >>> >>> struct S { >>> void f(this auto, Constrain auto) {}; >>> static void f(Constrain auto) {}; >>> >>> void g(this auto const&, Constrain auto) {}; >>> static void g(Constrain auto) {}; >>> >>> void h(this auto&&, Constrain auto) {}; >>> static void h(Constrain auto) {}; >>> }; >>> >>> And also, >>> >>> struct S{ >>> void f(this auto) {}; >>> static void f() {}; >>> >>> void g(this auto const&) {}; >>> static void g() {}; >>> >>> void h(this auto&&) {}; >>> static void h() {}; >>> }; >>> >>> I wrote these tests expecting them to be ill-formed, and found what I >>> thought was a bug when they were not diagnosed as redecelarations. >>> However, given how the code for resolving overloads and determining >>> redeclarations looks, I believe this is actually well formed on a >>> technicality. I can't find the passages in the standard that specify >>> this so I can't be sure. >> >> >> I think the relevant section is >> https://eel.is/c++draft/basic.scope.scope >> >>> Anyway, the template parameter list differs because of the deduced >>> object parameter. Now here is the question, you are required to ignore >>> the object parameter when determining if these are redeclarations or >>> not, but what about the template parameters associated with the object >>> parameter? Am I just missing the passage that specifies this or is this >>> an actual defect in the standard? >> >> >> I think that since they differ in template parameters, they don't >> correspond under https://eel.is/c++draft/basic.scope.scope#4.5 so they >> can be overloaded. >> >> This is specified in terms of the template-head grammar non-terminal, >> but elsewhere we say that abbreviated templates are equivalent to >> writing out the template parameters explicitly. >> >>> The annoying thing is, even if this was brought up, I think the only >>> solution is to ratify these examples as well formed. >> >> Yes. > > I can't get over that I feel like this goes against the spirit of the > specification. Just because an object argument is deduced should not > suddenly mean we take it into account. Too bad there's no good solution. Yep. Note that it's normal for a template to overload with a non-template: struct A { void f(); template void f(); // OK }; > I especially don't like that that the following case is ambiguous. I > understand why, but I don't like it. > > template > concept Constrain = true; > > struct S { > int f(this auto, Constrain auto) {}; > static f(auto) {}; > }; > main() { > S{}.f(0); > } > > I would like to see this changed honestly. When an ambiguity is > encountered, the more constrained function should be taken into account > even if they normally can't be considered. Is there some pitfall with > this line of thinking that kept it out of the standard? Is it just a > case of "too hard to specify" or is there some reason it's impossible > to do in all but the simplest of cases? I would actually expect the static function to be chosen as more specialized before we get to considering constraints, just as with void f(auto, Constrain auto) = delete; void f(const S&, auto) {} int main() { f(S{},0); } // OK Though it looks like [temp.func.order] needs to be adjusted for explicit object parameters. And more_specialized_fn in gcc still has an outdated handling of object parameters that just skips them, from before the clearer specification in C++11 and later; this is PR53499. No need to address that preexisting bug in this patch. Jason