mirror of
https://github.com/apple/swift.git
synced 2026-02-27 18:26:24 +01:00
Explicitly mark the dependency between the base pointer and the owner object. Otherwise the owner object could be destroyed too early. So far we got away with this because array semantic functions were not inlined in OSSA. Fixes a miscompile.
26 lines
515 B
Swift
26 lines
515 B
Swift
// RUN: %target-run-simple-swift(-O)
|
|
// REQUIRES: executable_test
|
|
// REQUIRES: reflection
|
|
|
|
import StdlibUnittest
|
|
|
|
let testSuite = TestSuite("ArraySlice")
|
|
|
|
@inline(never)
|
|
func getArray() -> [String] {
|
|
return [_opaqueIdentity("a very long string which is is not inlined")]
|
|
}
|
|
|
|
@inline(never)
|
|
func testSliceLiverange() -> String {
|
|
let a = getArray()
|
|
let s = a[0..<1]
|
|
return s[0]
|
|
}
|
|
|
|
testSuite.test("liverange") {
|
|
expectEqual(testSliceLiverange(), "a very long string which is is not inlined")
|
|
}
|
|
|
|
runAllTests()
|