[libcxx-commits] [PATCH] D69939: [libc++] Initialized variables for compilers that do not allow this in constexpr.

Michael Park via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Thu Nov 7 04:01:15 PST 2019


mpark created this revision.
mpark added a reviewer: ldionne.
Herald added a reviewer: EricWF.
Herald added subscribers: libcxx-commits, dexonsmith, christof.
Herald added a project: libc++.

In C++20, variables in constexpr contexts are not required to be initialized.
But there are released compilers that do not implement this under `-std=c++2a`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D69939

Files:
  libcxx/test/std/algorithms/alg.modifying.operations/alg.copy/copy.pass.cpp
  libcxx/test/std/algorithms/alg.modifying.operations/alg.copy/copy_backward.pass.cpp
  libcxx/test/std/algorithms/alg.modifying.operations/alg.copy/copy_if.pass.cpp
  libcxx/test/std/algorithms/alg.modifying.operations/alg.copy/copy_n.pass.cpp


Index: libcxx/test/std/algorithms/alg.modifying.operations/alg.copy/copy_n.pass.cpp
===================================================================
--- libcxx/test/std/algorithms/alg.modifying.operations/alg.copy/copy_n.pass.cpp
+++ libcxx/test/std/algorithms/alg.modifying.operations/alg.copy/copy_n.pass.cpp
@@ -26,7 +26,7 @@
 test_copy_n()
 {
     const unsigned N = 1000;
-    int ia[N];
+    int ia[N] = {};
     for (unsigned i = 0; i < N; ++i)
         ia[i] = i;
     int ib[N] = {0};
Index: libcxx/test/std/algorithms/alg.modifying.operations/alg.copy/copy_if.pass.cpp
===================================================================
--- libcxx/test/std/algorithms/alg.modifying.operations/alg.copy/copy_if.pass.cpp
+++ libcxx/test/std/algorithms/alg.modifying.operations/alg.copy/copy_if.pass.cpp
@@ -30,7 +30,7 @@
 test_copy_if()
 {
     const unsigned N = 1000;
-    int ia[N];
+    int ia[N] = {};
     for (unsigned i = 0; i < N; ++i)
         ia[i] = i;
     int ib[N] = {0};
Index: libcxx/test/std/algorithms/alg.modifying.operations/alg.copy/copy_backward.pass.cpp
===================================================================
--- libcxx/test/std/algorithms/alg.modifying.operations/alg.copy/copy_backward.pass.cpp
+++ libcxx/test/std/algorithms/alg.modifying.operations/alg.copy/copy_backward.pass.cpp
@@ -25,7 +25,7 @@
 test_copy_backward()
 {
     const unsigned N = 1000;
-    int ia[N];
+    int ia[N] = {};
     for (unsigned i = 0; i < N; ++i)
         ia[i] = i;
     int ib[N] = {0};
Index: libcxx/test/std/algorithms/alg.modifying.operations/alg.copy/copy.pass.cpp
===================================================================
--- libcxx/test/std/algorithms/alg.modifying.operations/alg.copy/copy.pass.cpp
+++ libcxx/test/std/algorithms/alg.modifying.operations/alg.copy/copy.pass.cpp
@@ -23,7 +23,7 @@
 test_copy()
 {
     const unsigned N = 1000;
-    int ia[N];
+    int ia[N] = {};
     for (unsigned i = 0; i < N; ++i)
         ia[i] = i;
     int ib[N] = {0};


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D69939.228208.patch
Type: text/x-patch
Size: 2012 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20191107/8c80f094/attachment.bin>


More information about the libcxx-commits mailing list