Skip to content

Commit 591e3a3

Browse files
committed
[Test] Fix deinit_escape test.
When compiled with optimizations, the compiler saw that C() doesn't escape and stack promoted it, which breaks the check. Deliberately escape the object into a global array beforehand to ensure it has to be on the heap. rdar://103369708
1 parent b8a3bbb commit 591e3a3

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

test/Runtime/deinit_escape.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,19 @@ import StdlibUnittest
88

99
var DeinitEscapeTestSuite = TestSuite("DeinitEscape")
1010

11-
var globalObjects: [AnyObject] = []
11+
var globalObjects1: [AnyObject] = []
12+
var globalObjects2: [AnyObject] = []
1213

1314
DeinitEscapeTestSuite.test("deinit escapes self") {
1415
expectCrashLater()
1516

1617
class C {
1718
deinit {
18-
globalObjects.append(self)
19+
globalObjects2.append(self)
1920
}
2021
}
21-
_ = C()
22+
globalObjects1.append(C())
23+
globalObjects1 = []
2224

2325
expectUnreachable()
2426
}

0 commit comments

Comments
 (0)