* [committed 1/2] libstdc++: Fix compilation with released versions of Clang
@ 2020-03-18 13:00 Jonathan Wakely
2020-03-18 13:01 ` [committed 2/2] libstdc++: Fix compilation of <stop_token> with Clang Jonathan Wakely
0 siblings, 1 reply; 2+ messages in thread
From: Jonathan Wakely @ 2020-03-18 13:00 UTC (permalink / raw)
To: libstdc++, gcc-patches
[-- Attachment #1: Type: text/plain, Size: 699 bytes --]
Clang 9 supports C++20 via -std=c++2a but doesn't support Concepts, so
several of the new additions related to the Ranges library fail to
compile with -std=c++2a. The new definition of iterator_traits and the
definition of default_sentinel_t are guarded by __cpp_lib_concepts, so
check that in addition to __cplusplus > 201703L.
* include/bits/stl_algobase.h (__lexicographical_compare_aux): Check
__cpp_lib_concepts before using iter_reference_t.
* include/bits/stream_iterator.h (istream_iterator): Check
__cpp_lib_concepts before using default_sentinel_t.
* include/bits/streambuf_iterator.h (istreambuf_iterator): Likewise.
Tested powerpc64le-linux, committed to master.
[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 3459 bytes --]
commit 07522ae90b5bae2ca95b64f3a4de60bea0cc0567
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Wed Mar 18 12:55:29 2020 +0000
libstdc++: Fix compilation with released versions of Clang
Clang 9 supports C++20 via -std=c++2a but doesn't support Concepts, so
several of the new additions related to the Ranges library fail to
compile with -std=c++2a. The new definition of iterator_traits and the
definition of default_sentinel_t are guarded by __cpp_lib_concepts, so
check that in addition to __cplusplus > 201703L.
* include/bits/stl_algobase.h (__lexicographical_compare_aux): Check
__cpp_lib_concepts before using iter_reference_t.
* include/bits/stream_iterator.h (istream_iterator): Check
__cpp_lib_concepts before using default_sentinel_t.
* include/bits/streambuf_iterator.h (istreambuf_iterator): Likewise.
diff --git a/libstdc++-v3/include/bits/stl_algobase.h b/libstdc++-v3/include/bits/stl_algobase.h
index 8f3ca885f03..a7e92d4b473 100644
--- a/libstdc++-v3/include/bits/stl_algobase.h
+++ b/libstdc++-v3/include/bits/stl_algobase.h
@@ -1283,7 +1283,7 @@ _GLIBCXX_END_NAMESPACE_CONTAINER
&& !__gnu_cxx::__numeric_traits<_ValueType2>::__is_signed
&& __is_pointer<_II1>::__value
&& __is_pointer<_II2>::__value
-#if __cplusplus > 201703L
+#if __cplusplus > 201703L && __cpp_lib_concepts
// For C++20 iterator_traits<volatile T*>::value_type is non-volatile
// so __is_byte<T> could be true, but we can't use memcmp with
// volatile data.
diff --git a/libstdc++-v3/include/bits/stream_iterator.h b/libstdc++-v3/include/bits/stream_iterator.h
index 9d8ead092b8..bd5ba2a80c0 100644
--- a/libstdc++-v3/include/bits/stream_iterator.h
+++ b/libstdc++-v3/include/bits/stream_iterator.h
@@ -77,7 +77,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_M_ok(__obj._M_ok)
{ }
-#if __cplusplus > 201703L
+#if __cplusplus > 201703L && __cpp_lib_concepts
constexpr
istream_iterator(default_sentinel_t)
noexcept(is_nothrow_default_constructible_v<_Tp>)
@@ -153,7 +153,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
operator!=(const istream_iterator& __x, const istream_iterator& __y)
{ return !__x._M_equal(__y); }
-#if __cplusplus > 201703L
+#if __cplusplus > 201703L && __cpp_lib_concepts
friend bool
operator==(const istream_iterator& __i, default_sentinel_t)
{ return !__i._M_stream; }
diff --git a/libstdc++-v3/include/bits/streambuf_iterator.h b/libstdc++-v3/include/bits/streambuf_iterator.h
index fc06c50040c..d3f1610fc8d 100644
--- a/libstdc++-v3/include/bits/streambuf_iterator.h
+++ b/libstdc++-v3/include/bits/streambuf_iterator.h
@@ -115,7 +115,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_GLIBCXX_CONSTEXPR istreambuf_iterator() _GLIBCXX_USE_NOEXCEPT
: _M_sbuf(0), _M_c(traits_type::eof()) { }
-#if __cplusplus > 201703L
+#if __cplusplus > 201703L && __cpp_lib_concepts
constexpr istreambuf_iterator(default_sentinel_t) noexcept
: istreambuf_iterator() { }
#endif
@@ -215,7 +215,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
return traits_type::eq_int_type(__c, __eof);
}
-#if __cplusplus > 201703L
+#if __cplusplus > 201703L && __cpp_lib_concepts
friend bool
operator==(const istreambuf_iterator& __i, default_sentinel_t __s)
{ return __i._M_at_eof(); }
^ permalink raw reply [flat|nested] 2+ messages in thread
* [committed 2/2] libstdc++: Fix compilation of <stop_token> with Clang
2020-03-18 13:00 [committed 1/2] libstdc++: Fix compilation with released versions of Clang Jonathan Wakely
@ 2020-03-18 13:01 ` Jonathan Wakely
0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Wakely @ 2020-03-18 13:01 UTC (permalink / raw)
To: libstdc++, gcc-patches
[-- Attachment #1: Type: text/plain, Size: 623 bytes --]
Clang 9 supports C++20 via -std=c++2a but doesn't support three-way
comparisons, so <stop_token> fails to compile. When the compiler doesn't
support default comparisons, this patch defines operator== and
operator!= for the _Stop_state_ref class. That is enough for the header
to be compiled with Clang. It allows operator== for stop_token and
stop_source to work, but not operator!= because that isn't explicitly
defined.
* include/std/stop_token (stop_token::_Stop_state_ref): Define
comparison operators explicitly if the compiler won't synthesize them.
Tested powerpc64le-linux, committed to master.
[-- Attachment #2: patch.txt --]
[-- Type: text/x-patch, Size: 1726 bytes --]
commit e5de406f9967ef4b0bbdbcbc0320869d2bf04558
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Wed Mar 18 12:55:29 2020 +0000
libstdc++ Fix compilation of <stop_token> with Clang
Clang 9 supports C++20 via -std=c++2a but doesn't support three-way
comparisons, so <stop_token> fails to compile. When the compiler doesn't
support default comparisons, this patch defines operator== and
operator!= for the _Stop_state_ref class. That is enough for the header
to be compiled with Clang. It allows operator== for stop_token and
stop_source to work, but not operator!= because that isn't explicitly
defined.
* include/std/stop_token (stop_token::_Stop_state_ref): Define
comparison operators explicitly if the compiler won't synthesize them.
diff --git a/libstdc++-v3/include/std/stop_token b/libstdc++-v3/include/std/stop_token
index 6fb8ae05197..87beb08c71d 100644
--- a/libstdc++-v3/include/std/stop_token
+++ b/libstdc++-v3/include/std/stop_token
@@ -456,8 +456,20 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_Stop_state_t* operator->() const noexcept { return _M_ptr; }
+#if __cpp_impl_three_way_comparison >= 201907L
friend bool
operator==(const _Stop_state_ref&, const _Stop_state_ref&) = default;
+#else
+ friend bool
+ operator==(const _Stop_state_ref& __lhs, const _Stop_state_ref& __rhs)
+ noexcept
+ { return __lhs._M_ptr == __rhs._M_ptr; }
+
+ friend bool
+ operator!=(const _Stop_state_ref& __lhs, const _Stop_state_ref& __rhs)
+ noexcept
+ { return __lhs._M_ptr != __rhs._M_ptr; }
+#endif
private:
_Stop_state_t* _M_ptr = nullptr;
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-03-18 13:02 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-18 13:00 [committed 1/2] libstdc++: Fix compilation with released versions of Clang Jonathan Wakely
2020-03-18 13:01 ` [committed 2/2] libstdc++: Fix compilation of <stop_token> with Clang Jonathan Wakely
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).