mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
COWArrayOpts wrongly assumed that an 'owned' argument is released in the function. https://bugs.swift.org/browse/SR-12440 rdar://problem/62201043
24 lines
551 B
Swift
24 lines
551 B
Swift
// RUN: %target-run-simple-swift(-O) | %FileCheck %s
|
|
|
|
// REQUIRES: executable_test
|
|
|
|
|
|
@inline(never)
|
|
func testit(_ input: [[Int]]) -> [[Int]] {
|
|
var result : [[Int]] = []
|
|
for inputElementArray in input {
|
|
var mutableElementArray = inputElementArray
|
|
for _ in 0..<2 {
|
|
// The COW-check for 'mutableElementArray' must not be hoisted out of this loop.
|
|
for i in 0..<1 {
|
|
mutableElementArray[i] += 1
|
|
}
|
|
result.append(mutableElementArray)
|
|
}
|
|
}
|
|
return result
|
|
}
|
|
|
|
// CHECK: {{\[\[1\], \[2\]\]}}
|
|
print(testit([[0]]))
|