* Re: Add workaround to std::variant for Clang bug 31852
2018-03-26 13:13 Add workaround to std::variant for Clang bug 31852 Jonathan Wakely
@ 2018-03-26 14:14 ` Jonathan Wakely
2018-04-07 15:13 ` Gerald Pfeifer
2018-04-05 16:59 ` Jonathan Wakely
1 sibling, 1 reply; 4+ messages in thread
From: Jonathan Wakely @ 2018-03-26 14:14 UTC (permalink / raw)
To: libstdc++, gcc-patches
[-- Attachment #1: Type: text/plain, Size: 574 bytes --]
Now with 100% more patch.
On 26 March 2018 at 14:10, Jonathan Wakely <jwakely.gcc@gmail.com> wrote:
> This makes it possible to use our std::variant with Clang, as well as
> some minor tweaks to avoid ADL (so the compiler doesn't waste time
> looking in associated namespaces) and adjust whitespace.
>
> * include/std/variant (__get): Qualify calls to avoid ADL.
> (__select_index): Adjust whitespace.
> (variant): Add using-declaration to workaround Clang bug.
>
> Tested powerpc64le-linux, committed to trunk.. I'll backport to
> gcc-7-branch too.
[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 2126 bytes --]
commit 4b3007fd674c489b695b8b1c52d6f1e8d010f072
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Mon Mar 26 13:49:34 2018 +0100
Add workaround to std::variant for Clang bug 31852
* include/std/variant (__get): Qualify calls to avoid ADL.
(__select_index): Adjust whitespace.
(variant): Add using-declaration to workaround Clang bug.
diff --git a/libstdc++-v3/include/std/variant b/libstdc++-v3/include/std/variant
index 4aba131cb73..e4ae6573ed4 100644
--- a/libstdc++-v3/include/std/variant
+++ b/libstdc++-v3/include/std/variant
@@ -223,13 +223,17 @@ namespace __variant
template<size_t _Np, typename _Union>
constexpr decltype(auto) __get(in_place_index_t<_Np>, _Union&& __u)
- { return __get(in_place_index<_Np-1>, std::forward<_Union>(__u)._M_rest); }
+ {
+ return __variant::__get(in_place_index<_Np-1>,
+ std::forward<_Union>(__u)._M_rest);
+ }
// Returns the typed storage for __v.
template<size_t _Np, typename _Variant>
constexpr decltype(auto) __get(_Variant&& __v)
{
- return __get(std::in_place_index<_Np>, std::forward<_Variant>(__v)._M_u);
+ return __variant::__get(std::in_place_index<_Np>,
+ std::forward<_Variant>(__v)._M_u);
}
// Various functions as "vtable" entries, where those vtables are used by
@@ -358,10 +362,9 @@ namespace __variant
template <typename... _Types>
using __select_index =
- typename __select_int::_Select_int_base<sizeof...(_Types)+1,
+ typename __select_int::_Select_int_base<sizeof...(_Types) + 1,
unsigned char,
- unsigned short>
- ::type::value_type;
+ unsigned short>::type::value_type;
template<typename... _Types>
struct _Variant_storage<false, _Types...>
@@ -1304,6 +1307,12 @@ namespace __variant
#undef _VARIANT_RELATION_FUNCTION_TEMPLATE
+#ifdef __clang__
+ public:
+ using _Base::_M_u; // See https://bugs.llvm.org/show_bug.cgi?id=31852
+ private:
+#endif
+
template<size_t _Np, typename _Vp>
friend constexpr decltype(auto) __detail::__variant::__get(_Vp&& __v);
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Add workaround to std::variant for Clang bug 31852
2018-03-26 13:13 Add workaround to std::variant for Clang bug 31852 Jonathan Wakely
2018-03-26 14:14 ` Jonathan Wakely
@ 2018-04-05 16:59 ` Jonathan Wakely
1 sibling, 0 replies; 4+ messages in thread
From: Jonathan Wakely @ 2018-04-05 16:59 UTC (permalink / raw)
To: libstdc++, gcc-patches
[-- Attachment #1: Type: text/plain, Size: 708 bytes --]
On 26 March 2018 at 14:10, Jonathan Wakely wrote:
> This makes it possible to use our std::variant with Clang, as well as
> some minor tweaks to avoid ADL (so the compiler doesn't waste time
> looking in associated namespaces) and adjust whitespace.
>
> * include/std/variant (__get): Qualify calls to avoid ADL.
> (__select_index): Adjust whitespace.
> (variant): Add using-declaration to workaround Clang bug.
>
> Tested powerpc64le-linux, committed to trunk.. I'll backport to
> gcc-7-branch too.
The Clang bug means that __get is ambiguous (because it thinks the
friend declaration is a separate overload) so we also need this
change.
Tested powerpc64le-linux, committed to trunk.
[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 999 bytes --]
commit c09f881053d98370306098b7bad5bb829255379c
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Thu Apr 5 14:03:13 2018 +0100
Add another workaround to std::variant for Clang bug 31852
* include/std/variant (_VARIANT_RELATION_FUNCTION_TEMPLATE): Qualify
__get calls to avoid ADL and avoid ambiguity due to Clang bug.
diff --git a/libstdc++-v3/include/std/variant b/libstdc++-v3/include/std/variant
index 028d3064272..48bec528406 100644
--- a/libstdc++-v3/include/std/variant
+++ b/libstdc++-v3/include/std/variant
@@ -272,8 +272,8 @@ namespace __variant
constexpr bool \
__erased_##__NAME(const _Variant& __lhs, const _Variant& __rhs) \
{ \
- return __get<_Np>(std::forward<_Variant>(__lhs)) \
- __OP __get<_Np>(std::forward<_Variant>(__rhs)); \
+ return __variant::__get<_Np>(std::forward<_Variant>(__lhs)) \
+ __OP __variant::__get<_Np>(std::forward<_Variant>(__rhs)); \
}
_VARIANT_RELATION_FUNCTION_TEMPLATE(<, less)
^ permalink raw reply [flat|nested] 4+ messages in thread