[PATCH] D16344: [libcxx] Fix PR26103 - Error calling is_convertible with incomplete type

Michael Daniels via cfe-commits cfe-commits at lists.llvm.org
Fri Jan 22 07:16:54 PST 2016


mdaniels updated this revision to Diff 45685.

http://reviews.llvm.org/D16344

Files:
  include/type_traits
  test/std/utilities/meta/meta.rel/is_convertible.pass.cpp

Index: test/std/utilities/meta/meta.rel/is_convertible.pass.cpp
===================================================================
--- test/std/utilities/meta/meta.rel/is_convertible.pass.cpp
+++ test/std/utilities/meta/meta.rel/is_convertible.pass.cpp
@@ -52,6 +52,11 @@
   NonCopyable(NonCopyable&);
 };
 
+template <typename T>
+class CannotInstantiate {
+  enum { X = T::ThisExpressionWillBlowUp };
+};
+
 int main()
 {
     // void
@@ -206,4 +211,7 @@
     test_is_not_convertible<NonCopyable&, NonCopyable>();
 #endif
 
+    // Ensure that CannotInstantiate is not instantiated by is_convertible when it is not needed.
+    // For example CannotInstantiate is instatiated as a part of ADL lookup for arguments of type CannotInstantiate*.
+    static_assert((std::is_convertible<CannotInstantiate<int>*, CannotInstantiate<int>*>::value), "");
 }
Index: include/type_traits
===================================================================
--- include/type_traits
+++ include/type_traits
@@ -1347,10 +1347,9 @@
 
 template <class _From, class _To>
 struct __is_convertible_test<_From, _To,
-    decltype(__test_convert<_To>(_VSTD::declval<_From>()))> : public true_type
+    decltype(_VSTD::__is_convertible_imp::__test_convert<_To>(_VSTD::declval<_From>()))> : public true_type
 {};
 
-template <class _Tp> __two __test(...);
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
 template <class _Tp> _Tp&& __source();
 #else


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D16344.45685.patch
Type: text/x-patch
Size: 1423 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160122/dd7e76b4/attachment-0001.bin>


More information about the cfe-commits mailing list