Skip to content

Commit

Permalink
Fix ArrayRef initializer_list Ctor Test
Browse files Browse the repository at this point in the history
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
  • Loading branch information
dwblaikie committed Aug 25, 2016
1 parent a6ccc8d commit 68ce792
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion llvm/unittests/ADT/ArrayRefTest.cpp
Expand Up @@ -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]);

Expand Down

0 comments on commit 68ce792

Please sign in to comment.