[PATCH] D41977: [libc++] Fix PR20855 -- libc++ incorrectly diagnoses illegal reference binding in std::tuple.

Richard Smith - zygoloid via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jan 12 16:19:12 PST 2018


rsmith added inline comments.


================
Comment at: include/tuple:185-186
+        // Allow "int&&" to bind to 'int const&'
+        ||  (is_rvalue_reference<_Tp>::value && is_const<_RawHp>::value &&
+            is_same<_RawHp, const _RawTp>::value)
         >;
----------------
It would be reasonable to consider `is_base_of` here too.


================
Comment at: include/tuple:190
             || (is_lvalue_reference<_Hp>::value && _CheckLValueArg::value)
             || (is_rvalue_reference<_Hp>::value && !is_lvalue_reference<_Tp>::value);
+#else
----------------
This line looks wrong to me. This disallows an rvalue reference tuple member from binding to an rvalue reference argument, no? Can you
```
return !is_reference<_Hp>::value || (is_reference<_Tp>::value && is_convertible<_RawTp*, _RawHp*>::value) || (reference wrapper special case);
```
instead? That should at least only reject valid code in cases where `_RawTp` is a class type that converts to a reference type.


https://reviews.llvm.org/D41977





More information about the cfe-commits mailing list