[llvm] r279783 - Fix ArrayRef initializer_list Ctor Test

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 25 15:09:14 PDT 2016


Author: dblaikie
Date: Thu Aug 25 17:09:13 2016
New Revision: 279783

URL: http://llvm.org/viewvc/llvm-project?rev=279783&view=rev
Log:
Fix ArrayRef initializer_list Ctor Test

The InitializerList test had undefined behavior by creating a dangling pointer to the temporary initializer list.  This patch removes the undefined behavior in the test by creating the initializer list directly.

Reviewers: mehdi_amini, dblaikie

Differential Revision: https://reviews.llvm.org/D23890

Modified:
    llvm/trunk/unittests/ADT/ArrayRefTest.cpp

Modified: llvm/trunk/unittests/ADT/ArrayRefTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ADT/ArrayRefTest.cpp?rev=279783&r1=279782&r2=279783&view=diff
==============================================================================
--- llvm/trunk/unittests/ADT/ArrayRefTest.cpp (original)
+++ llvm/trunk/unittests/ADT/ArrayRefTest.cpp Thu Aug 25 17:09:13 2016
@@ -134,7 +134,8 @@ static void ArgTest12(ArrayRef<int> A) {
 }
 
 TEST(ArrayRefTest, InitializerList) {
-  ArrayRef<int> A = { 0, 1, 2, 3, 4 };
+  std::initializer_list<int> init_list = { 0, 1, 2, 3, 4 };
+  ArrayRef<int> A = init_list;
   for (int i = 0; i < 5; ++i)
     EXPECT_EQ(i, A[i]);
 




More information about the llvm-commits mailing list