From e01f946792f28d55e56ab3e3d918903a3c934c55 Mon Sep 17 00:00:00 2001 From: Eric Fiselier Date: Tue, 26 Jan 2016 20:24:30 +0000 Subject: [PATCH] Fix PR26103 - Error calling is_convertible with incomplete type. Patch from Michael Daniels. git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@258852 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/type_traits | 3 +-- test/std/utilities/meta/meta.rel/is_convertible.pass.cpp | 8 ++++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/include/type_traits b/include/type_traits index f13e29f97..3c9e8dd90 100644 --- a/include/type_traits +++ b/include/type_traits @@ -1347,10 +1347,9 @@ struct __is_convertible_test : public false_type {}; template 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 __two __test(...); #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template _Tp&& __source(); #else diff --git a/test/std/utilities/meta/meta.rel/is_convertible.pass.cpp b/test/std/utilities/meta/meta.rel/is_convertible.pass.cpp index 1681c3997..144c292b8 100644 --- a/test/std/utilities/meta/meta.rel/is_convertible.pass.cpp +++ b/test/std/utilities/meta/meta.rel/is_convertible.pass.cpp @@ -52,6 +52,11 @@ class NonCopyable { NonCopyable(NonCopyable&); }; +template +class CannotInstantiate { + enum { X = T::ThisExpressionWillBlowUp }; +}; + int main() { // void @@ -206,4 +211,7 @@ int main() test_is_not_convertible(); #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*>::value), ""); }