[PATCH] D13062: [libcxx] Fix PR24779 -- Prevent evaluation of std::is_default_constructible in clearly ill-formed tuple constructor.

Eric Fiselier via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 22 11:31:12 PDT 2015


EricWF created this revision.
EricWF added a reviewer: mclow.lists.
EricWF added a subscriber: cfe-commits.

This patch fixes PR24779 (https://llvm.org/bugs/show_bug.cgi?id=24779)


http://reviews.llvm.org/D13062

Files:
  include/tuple
  test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_UTypes_PR24779.pass.cpp

Index: test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_UTypes_PR24779.pass.cpp
===================================================================
--- /dev/null
+++ test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_UTypes_PR24779.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <class Alloc, class... UTypes>
+//   tuple(allocator_arg_t, const Alloc& a, UTypes&&...);
+
+// UNSUPPORTED: c++98, c++03
+
+// Check that this constructor does not evaluate
+// std::is_default_constructible<T> for any T in Types.
+
+#include <memory>
+#include <tuple>
+
+template <class Tp = void>
+struct BadDefaultCtor {
+    constexpr BadDefaultCtor() {
+        static_assert(!std::is_same<Tp, void>::value, "");
+    }
+
+    explicit BadDefaultCtor(int) {}
+};
+
+void DeleteFn(int*) {}
+
+int main() {
+    typedef BadDefaultCtor<> Type;
+    typedef std::tuple<Type, Type> Tuple;
+    Tuple t(Type(0), Type(0));
+}
Index: include/tuple
===================================================================
--- include/tuple
+++ include/tuple
@@ -635,7 +635,8 @@
                          >::value &&
                          __all_default_constructible<
                             typename __make_tuple_types<tuple, sizeof...(_Tp),
-                                sizeof...(_Up) < sizeof...(_Tp) ?
+                                sizeof...(_Up) < sizeof...(_Tp)
+                                && sizeof...(_Up) != 0 ?
                                     sizeof...(_Up) :
                                     sizeof...(_Tp)>::type
                          >::value


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D13062.35398.patch
Type: text/x-patch
Size: 1987 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150922/38a84eb1/attachment-0001.bin>


More information about the cfe-commits mailing list