mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
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
29 lines
521 B
Swift
29 lines
521 B
Swift
// RUN: %target-run-simple-swift
|
|
|
|
// REQUIRES: executable_test
|
|
// UNSUPPORTED: use_os_stdlib
|
|
// UNSUPPORTED: back_deployment_runtime
|
|
|
|
import StdlibUnittest
|
|
|
|
var DeinitEscapeTestSuite = TestSuite("DeinitEscape")
|
|
|
|
var globalObjects1: [AnyObject] = []
|
|
var globalObjects2: [AnyObject] = []
|
|
|
|
DeinitEscapeTestSuite.test("deinit escapes self") {
|
|
expectCrashLater()
|
|
|
|
class C {
|
|
deinit {
|
|
globalObjects2.append(self)
|
|
}
|
|
}
|
|
globalObjects1.append(C())
|
|
globalObjects1 = []
|
|
|
|
expectUnreachable()
|
|
}
|
|
|
|
runAllTests()
|