]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Fix linker errors for directory iterator comparisons
authorJonathan Wakely <jwakely@redhat.com>
Tue, 3 Oct 2023 16:41:14 +0000 (17:41 +0100)
committerJonathan Wakely <jwakely@redhat.com>
Tue, 3 Oct 2023 16:41:14 +0000 (17:41 +0100)
These new comparison operators for std::default_sentinel_t require some
new symbol exports, which were added with r13-5662-gdb8d6fc572ec31 for
trunk, but that isn't suitable for the gcc-12 branch.

Define them as specified in the standard instead, which doesn't require
any new symbols.

libstdc++-v3/ChangeLog:

* include/bits/fs_dir.h (directory_iterator::operator==):
Define without using a non-exported shared_ptr symbol.
(recursive_directory_iterator::operator==): Likewise.

libstdc++-v3/include/bits/fs_dir.h

index bec2b7674ef9dd79b65e18909010a149d434e959..84e8e8984e8a501ed33848dc2ef1e6cc8405733d 100644 (file)
@@ -433,7 +433,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
       // _GLIBCXX_RESOLVE_LIB_DEFECTS
       // 3719. Directory iterators should be usable with default sentinel
       bool operator==(default_sentinel_t) const noexcept
-      { return !_M_dir; }
+      { return *this == directory_iterator(); }
 #endif
 
 #if __cpp_impl_three_way_comparison < 201907L
@@ -541,7 +541,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
       // _GLIBCXX_RESOLVE_LIB_DEFECTS
       // 3719. Directory iterators should be usable with default sentinel
       bool operator==(default_sentinel_t) const noexcept
-      { return !_M_dirs; }
+      { return *this == recursive_directory_iterator(); }
 #endif
 
 #if __cpp_impl_three_way_comparison < 201907L