Files
swift-mirror/test/SILOptimizer/wrong_cow_arrayopt.swift
Erik Eckstein 54e54ae4fe COWArrayOpts: fix a mis-compile related to owned function arguments
COWArrayOpts wrongly assumed that an 'owned' argument is released in the function.

https://bugs.swift.org/browse/SR-12440
rdar://problem/62201043
2020-05-04 17:30:40 +02:00

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