浏览代码

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.
Chris B 2 年之前
父节点
当前提交
b0d5211b5a
共有 1 个文件被更改,包括 2 次插入1 次删除
  1. 2 1
      unittests/ADT/ArrayRefTest.cpp

+ 2 - 1
unittests/ADT/ArrayRefTest.cpp

@@ -99,7 +99,8 @@ static void ArgTest12(ArrayRef<int> A) {
 }
 
 TEST(ArrayRefTest, InitializerList) {
-  ArrayRef<int> A = { 0, 1, 2, 3, 4 };
+  std::initializer_list<int> InitList = { 0, 1, 2, 3, 4 };
+  ArrayRef<int> A = InitList;
   for (int i = 0; i < 5; ++i)
     EXPECT_EQ(i, A[i]);