mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
When an owned value has no lifetime ending uses it means that it is in a dead-end region. We must not remove and inserting compensating destroys for it because that would potentially destroy the value too early. Initialization of an object might be cut off and removed after a dead-end loop or an `unreachable`. In this case a class destructor would see uninitialized fields. Fixes a mis-compile https://github.com/swiftlang/swift/issues/85851 rdar://165876726
36 lines
547 B
Swift
36 lines
547 B
Swift
// RUN: %target-run-simple-swift(-O -Xllvm -sil-disable-pass=deadobject-elim) | %FileCheck %s
|
|
|
|
// REQUIRES: executable_test
|
|
|
|
#if canImport(Darwin)
|
|
import Darwin
|
|
#elseif canImport(Glibc)
|
|
import Glibc
|
|
#elseif os(WASI)
|
|
import WASILibc
|
|
#elseif canImport(Android)
|
|
import Android
|
|
#elseif os(Windows)
|
|
import CRT
|
|
#else
|
|
#error("Unsupported platform")
|
|
#endif
|
|
|
|
@inline(never)
|
|
public func hiddenExit() {
|
|
// CHECK: okay
|
|
print("okay")
|
|
exit(0)
|
|
}
|
|
|
|
func foo() -> Never {
|
|
while true {
|
|
hiddenExit()
|
|
}
|
|
}
|
|
|
|
func bar(_ x: Any...) {
|
|
}
|
|
|
|
bar(foo())
|