Files
swift-mirror/test/Runtime/deinit_escape.swift
Mike Ash 591e3a371c [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
2022-12-15 13:22:28 -05:00

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()