From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl1-x62b.google.com (mail-pl1-x62b.google.com [IPv6:2607:f8b0:4864:20::62b]) by sourceware.org (Postfix) with ESMTPS id 37640386FC15 for ; Mon, 14 Jun 2021 12:58:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 37640386FC15 Received: by mail-pl1-x62b.google.com with SMTP id e7so6508316plj.7 for ; Mon, 14 Jun 2021 05:58:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=z/do37FvPtfL32I0NNEqq+3gPdlSKR8OIPWgtBhWOrE=; b=kqfSzX5pHGKIhu6PYpkzhzc0LoQXdjltXaXOnYTzG9viq853wGV6yd8RxFD6FPK51r OgY+PQ4uFl5dTr3w7O9OzZtJcPLzhF0c4QO/yv2eV7febAoAIyvypI/QH74fl0mnuWvZ q90NTLXGmhOw7K7yUkvvMkzBt8dyL4PBSndtWS69G+rguSJHVcsXB4NlrfFUxC2rfSGD BLb1DaC/R0118GE1zSMJLadzvh0Lr8apipltDZjDfChFPqNln/Wg+eMBDoGOnqaEitYn BUtYwNauFFeT3Et85ihsnKFbEkD3F+h6kjoQe0CadscDwNXkmQAJgsgpyelSw9EA9luo RCYA== X-Gm-Message-State: AOAM533zYM5Fob0FtKoGwR/n/anofkqerROOcRBVYdtXEFOvTwPeR6Tb v0q9lj1te0x5WQJHPkXy7Z7ArTiklVQJL+rnUs7RUQ== X-Google-Smtp-Source: ABdhPJwwu2lQcHepiBzOzxY+twzbP2N+leffYGG+Pl9IIes7KBe6/rdC6Oo8cZnKBZpK9EdOYRgHbWAMLR/yaGxFITI= X-Received: by 2002:a17:90a:7345:: with SMTP id j5mr23321131pjs.64.1623675506117; Mon, 14 Jun 2021 05:58:26 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Christophe Lyon Date: Mon, 14 Jun 2021 14:58:15 +0200 Message-ID: Subject: Re: [committed] libstdc++: Fix filesystem::path comparisons for C++23 To: Jonathan Wakely Cc: "libstdc++" , gcc Patches Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, KAM_NUMSUBJECT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=no autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libstdc++@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++ mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 14 Jun 2021 12:58:29 -0000 Hi Jonathan, On Fri, 11 Jun 2021 at 20:25, Jonathan Wakely via Gcc-patches wrote: > > In C++23 there is a basic_string_view(Range&&) constructor, which is > constrained to take a range (specifically, a contiguous_range). When the > filesystem::path comparison operators call lhs.compare(rhs) the overload > taking a string_view is considered, which means checking whether path > satisfies the range concept. That satisfaction result changes depending > whether path::iterator is complete, which is ill-formed; no diagnostic > required. To avoid the problem, this change ensures that the overload > resolution is performed in a context where path::iterator is complete > and the range concept is satisfied. (The result of overload resolution > is always that the compare(const path&) overload is the best match, but > we still have to consider the compare(basic_string_view) one > to decide if it even participates in overload resolution). > > For std::filesystem::path we can't define the comparison operators later > in the file, because they are hidden friends, so a new helper is > introduced that gets defined when everything else is complete. > > For std::experimental::filesystem::path we can just move the definitions > of the comparison operators later in the file. > > Signed-off-by: Jonathan Wakely > > libstdc++-v3/ChangeLog: > > * include/bits/fs_path.h (operator==, operator<=>): Use new > _S_compare function. > (path::_S_compare): New function to call path::compare in a > context where path::iterator is complete. > * include/experimental/bits/fs_path.h (operator<, operator==): > Define after path::iterator is complete. > * testsuite/27_io/filesystem/path/native/conv_c++23.cc: New > test. > * testsuite/experimental/filesystem/path/native/conv_c++23.cc: > New test. > > Tested powerpc64le-linux. Committed to trunk. > > This also needs to be backported to gcc-11 where the string_view > constructor is present for C++23 mode. > The new test experimental/filesystem/path/native/conv_c++23.cc fails on arm-eabi and aarch64-elf: /libstdc++-v3/testsuite/experimental/filesystem/path/native/conv_c++23.cc:4: fatal error: experimental/filesystem: No such file or directory (both trunk and gcc-11) I guess that's easy to fix? :-) Thanks, Christophe