diff options
author | David Blaikie <dblaikie@gmail.com> | 2016-08-25 22:09:13 +0000 |
---|---|---|
committer | David Blaikie <dblaikie@gmail.com> | 2016-08-25 22:09:13 +0000 |
commit | 68ce7928dc9160e8672e8b8f10ab620faea54d38 (patch) | |
tree | da2508fa197345c244f580ca9571f018c18e937f | |
parent | a6ccc8d365fadcac1e5ecfe6c3ac78c3aa7f9b61 (diff) | |
download | llvm-68ce7928dc9160e8672e8b8f10ab620faea54d38.zip llvm-68ce7928dc9160e8672e8b8f10ab620faea54d38.tar.gz llvm-68ce7928dc9160e8672e8b8f10ab620faea54d38.tar.bz2 |
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
llvm-svn: 279783
-rw-r--r-- | llvm/unittests/ADT/ArrayRefTest.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/llvm/unittests/ADT/ArrayRefTest.cpp b/llvm/unittests/ADT/ArrayRefTest.cpp index b5b71f0..132be35 100644 --- a/llvm/unittests/ADT/ArrayRefTest.cpp +++ b/llvm/unittests/ADT/ArrayRefTest.cpp @@ -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]); |