summaryrefslogtreecommitdiffstats
path: root/libcxx/test/utilities/function.objects/func.wrap/func.wrap.func
diff options
context:
space:
mode:
authorMarshall Clow <mclow.lists@gmail.com>2014-06-30 21:27:51 +0000
committerMarshall Clow <mclow.lists@gmail.com>2014-06-30 21:27:51 +0000
commit38cae6330b3e41fb4c81f6fbdb98b4c8c5b159a8 (patch)
tree0ab63ce833c8f17b8036adea441fb78f80345208 /libcxx/test/utilities/function.objects/func.wrap/func.wrap.func
parentaf245d115bfab4eb0ca1b969b2aae6f84eb90706 (diff)
downloadbcm5719-llvm-38cae6330b3e41fb4c81f6fbdb98b4c8c5b159a8.tar.gz
bcm5719-llvm-38cae6330b3e41fb4c81f6fbdb98b4c8c5b159a8.zip
Fix libc++ bug #20039: 'Constructing std::function from empty compatible std::function results in half-empty state' Thanks to Agustin Berge for the report, and for his and Eric Fiselier's work on a fix.
llvm-svn: 212070
Diffstat (limited to 'libcxx/test/utilities/function.objects/func.wrap/func.wrap.func')
-rw-r--r--libcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy.pass.cpp12
-rw-r--r--libcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/no-variadics.pass.cpp24
2 files changed, 36 insertions, 0 deletions
diff --git a/libcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy.pass.cpp b/libcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy.pass.cpp
index 0efb4d9ac25..cf7b96314f7 100644
--- a/libcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy.pass.cpp
+++ b/libcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy.pass.cpp
@@ -99,6 +99,18 @@ int main()
assert(f2.target<int(*)(int)>() == 0);
assert(f2.target<A>() == 0);
}
+ {
+ std::function<int(int)> f;
+ assert(new_called == 0);
+ assert(f.target<int(*)(int)>() == 0);
+ assert(f.target<A>() == 0);
+ assert(!f);
+ std::function<long(int)> g = f;
+ assert(new_called == 0);
+ assert(g.target<long(*)(int)>() == 0);
+ assert(g.target<A>() == 0);
+ assert(!g);
+ }
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
assert(new_called == 0);
{
diff --git a/libcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/no-variadics.pass.cpp b/libcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/no-variadics.pass.cpp
new file mode 100644
index 00000000000..7099c45fab8
--- /dev/null
+++ b/libcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/no-variadics.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// class function<R()>
+
+// template<class F> function(F);
+
+#define _LIBCPP_HAS_NO_VARIADICS
+#include <functional>
+#include <cassert>
+
+int main()
+{
+ std::function<void()> f(static_cast<void(*)()>(0));
+ assert(!f);
+}
OpenPOWER on IntegriCloud