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 2C67C385F021 for ; Fri, 27 Oct 2023 20:34:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2C67C385F021 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 2C67C385F021 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=1698438874; cv=none; b=ozfTJtd/GFLnn+d4lpVq5qkn40XhLNS21WtJ9OeKmFbVnimvZuRArne+0l2prpjx0JpZ9hNzA/IuAMYO2Ml5Z3H/ejG4PpbuxLGNZjSct+OYGmIdQRpzmD7iwD9nYTsL3WOXdP0A4CAhlSf2VvJkO9N5NwHllZifA2jYoB5FbWU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698438874; c=relaxed/simple; bh=xnJ3g8l8jD+MmOddDnafUQ+62iYJONC/UPp/dokKVeo=; h=DKIM-Signature:From:Date:To:Subject:Message-ID:MIME-Version; b=PI1g62om6uNrm7raM+7wEsRyXE5vGyWxbYduHZm1d8Fr85R4H+S3rM8OhR8rFbSo+G9Q/tm7xrWlkan42raU7aBINNfflxwFilRZe/HewcCYBig5YBtlCEaUc2R7xZjpBiJp7wGzO8kMSjW+VGd0EQ7Ctok9ehg0vkiQI06HHaY= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1698438872; 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: in-reply-to:in-reply-to:references:references; bh=fX7u4DXBWokRXgMhPef15dwbIl/QLADkbndUzodxdHw=; b=H1lYzw2uTBSbWASF9kdP6RMQ00lO5sYtoA7XUO12J9Wgi33BPslFL3JAb2kJzILZSjo6bM qH4td+l1LW1S0+2JarP+TArJhLlB7f1KxkGVcBXZu+3Q+q2yZSkRJZ7VEEwRVxLW1pA7b1 MvIGxFDH8PPlKNdsMZLrNEoepAO4TzA= Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-114-G-kDqCRHMwexY57idYGvWg-1; Fri, 27 Oct 2023 16:34:31 -0400 X-MC-Unique: G-kDqCRHMwexY57idYGvWg-1 Received: by mail-qk1-f200.google.com with SMTP id af79cd13be357-778a2e847f4so320976985a.0 for ; Fri, 27 Oct 2023 13:34:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698438871; x=1699043671; h=mime-version:references:message-id:in-reply-to:subject:cc:to:date :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=fX7u4DXBWokRXgMhPef15dwbIl/QLADkbndUzodxdHw=; b=eajZ6Siremizlb0O49cjDeL4rTLZP239SG36xVDhySQtFUccutUIqvK68EeFHv4aUS I7lwI9duT+WXrHac8JdMn38ej1KRErqPWh5Z1t8XC+lfvlNRz+0UrcAWKP45kDFv//fG dclVH2lD0rs8DYVYgiK1MsakR2BmtM83qhJUrnetbYGqTu2B1KMApSRdPBQ94dFqGVmb W8nBwzBETNHTm/MDVVdlSqd9xkMHJ+vm/iE5MpxnL+1eYY7D9cwESaJjPSKYyL4dKHo1 AlA6TJi8IgNtqMXl7w7UmV639pV9OLGLf9h25wjNLhaKRUzoCiimWbHa7+tYueqGDUan nEdQ== X-Gm-Message-State: AOJu0YyBYRfMZnrQnxNGl55swgwCc1FPpLQN9LCNhMngaIbUX1u+xdmX 0btqz5T1yfohIMbCD/jnRJU0+VznEFl+q/iOFEumA8bnEtj3B2SGhWhIY1x8FwmOee4k3DNQNd4 wtXTOiPKYu2BwGK4dxg== X-Received: by 2002:a05:6214:1313:b0:66d:18ec:8e6f with SMTP id pn19-20020a056214131300b0066d18ec8e6fmr4704828qvb.39.1698438871067; Fri, 27 Oct 2023 13:34:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHN7sxLlkFRL0ppHFZvwuxoOp6ICJaNL3auqz3vj5J7fMtDItCRCm1DN4vCthBUEIRa2x9leg== X-Received: by 2002:a05:6214:1313:b0:66d:18ec:8e6f with SMTP id pn19-20020a056214131300b0066d18ec8e6fmr4704813qvb.39.1698438870810; Fri, 27 Oct 2023 13:34:30 -0700 (PDT) Received: from [192.168.1.130] (ool-457670bb.dyn.optonline.net. [69.118.112.187]) by smtp.gmail.com with ESMTPSA id w19-20020ac86b13000000b00418be3e365fsm908302qts.1.2023.10.27.13.34.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Oct 2023 13:34:30 -0700 (PDT) From: Patrick Palka X-Google-Original-From: Patrick Palka Date: Fri, 27 Oct 2023 16:34:29 -0400 (EDT) To: Patrick Palka cc: Jason Merrill , gcc-patches@gcc.gnu.org Subject: Re: [pushed] c++: fix tourney logic In-Reply-To: Message-ID: References: <20231020202953.2247779-1-jason@redhat.com> <7261a90e-25b6-9d4f-da32-cbc09487f2a8@idea> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-13.8 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_H3,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 Fri, 27 Oct 2023, Patrick Palka wrote: > On Fri, 27 Oct 2023, Patrick Palka wrote: > > > On Fri, 20 Oct 2023, Jason Merrill wrote: > > > > > Tested x86_64-pc-linux-gnu, applying to trunk. Patrick, sorry I didn't apply > > > this sooner. > > > > > > -- 8< -- > > > > > > In r13-3766 I changed the logic at the end of tourney to avoid redundant > > > comparisons, but the change also meant skipping any less-good matches > > > between the champ_compared_to_predecessor candidate and champ itself. > > > > > > This should not be a correctness issue, since we believe that joust is a > > > partial order. But it can lead to missed warnings, as in this testcase. > > > > I suppose this rules out optimizing tourney via transitivity when in > > a non-SFINAE context since it'd cause missed warnings such as these. > > But maybe we'd still want to optimize the second pass via transitivity > > in a SFINAE context? > > Eh, maybe it's not worth it either way.. According to some quick > experiments, making the second pass in tourney assume transitivity by > going up to the most recent tie even in non-SFINAE contexts reduces the > total number of non-trivial calls to tourney by about 5%. Doing the total number of non-trivial calls to joust, rather > same in only SFINAE contexts reduces the number of calls by less than 1%. > > > > > > > > > gcc/cp/ChangeLog: > > > > > > * call.cc (tourney): Only skip champ_compared_to_predecessor. > > > > > > gcc/testsuite/ChangeLog: > > > > > > * g++.dg/warn/Wsign-promo1.C: New test. > > > --- > > > gcc/cp/call.cc | 5 +++-- > > > gcc/testsuite/g++.dg/warn/Wsign-promo1.C | 15 +++++++++++++++ > > > 2 files changed, 18 insertions(+), 2 deletions(-) > > > create mode 100644 gcc/testsuite/g++.dg/warn/Wsign-promo1.C > > > > > > diff --git a/gcc/cp/call.cc b/gcc/cp/call.cc > > > index 657eca93d23..a49fde949d5 100644 > > > --- a/gcc/cp/call.cc > > > +++ b/gcc/cp/call.cc > > > @@ -13227,10 +13227,11 @@ tourney (struct z_candidate *candidates, tsubst_flags_t complain) > > > been compared to. */ > > > > > > for (challenger = candidates; > > > - challenger != champ > > > - && challenger != champ_compared_to_predecessor; > > > + challenger != champ; > > > challenger = challenger->next) > > > { > > > + if (challenger == champ_compared_to_predecessor) > > > + continue; > > > fate = joust (champ, challenger, 0, complain); > > > if (fate != 1) > > > return NULL; > > > diff --git a/gcc/testsuite/g++.dg/warn/Wsign-promo1.C b/gcc/testsuite/g++.dg/warn/Wsign-promo1.C > > > new file mode 100644 > > > index 00000000000..51b76eee735 > > > --- /dev/null > > > +++ b/gcc/testsuite/g++.dg/warn/Wsign-promo1.C > > > @@ -0,0 +1,15 @@ > > > +// Check that we get joust warnings from comparing the final champ to a > > > +// candidate between it and the previous champ. > > > + > > > +// { dg-additional-options -Wsign-promo } > > > + > > > +struct A { A(int); }; > > > + > > > +enum E { e }; > > > + > > > +int f(int, A); > > > +int f(unsigned, A); > > > +int f(int, int); > > > + > > > +int i = f(e, 42); // { dg-warning "passing 'E'" } > > > +// { dg-warning "in call to 'int f" "" { target *-*-* } .-1 } > > > > > > base-commit: 084addf8a700fab9222d4127ab8524920d0ca481 > > > -- > > > 2.39.3 > > > > > > > > >