Skip to content

Commit b0d5211

Browse files
authored
Fix failing LLVM ArrayRef unit test (#4800)
The initializer list goes out of scope after the expression it is used in, so the ArrayRef points to invalid memory. This change keeps the initialization list around so that the array ref remains valid through the test.
1 parent 8869654 commit b0d5211

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

unittests/ADT/ArrayRefTest.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@ static void ArgTest12(ArrayRef<int> A) {
9999
}
100100

101101
TEST(ArrayRefTest, InitializerList) {
102-
ArrayRef<int> A = { 0, 1, 2, 3, 4 };
102+
std::initializer_list<int> InitList = { 0, 1, 2, 3, 4 };
103+
ArrayRef<int> A = InitList;
103104
for (int i = 0; i < 5; ++i)
104105
EXPECT_EQ(i, A[i]);
105106

0 commit comments

Comments
 (0)