mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
DeferCleanup pushes a new temporary cleanup to catch non-local returns from the defer block, so we have to use stable iterators while emitting cleanups. There's no good deterministic test case for this -- it would manifest as memory corruption if the underlying storage of the DiverseStack grew beyond the inline storage. Add a reduced version of the original user-reported test case that triggers it reliably -- I had a hard time coming up with anything simpler. Fixes <rdar://problem/21437203>. Swift SVN r29658
31 lines
470 B
Swift
31 lines
470 B
Swift
// RUN: %target-swift-frontend %s -emit-silgen
|
|
|
|
struct Curds {
|
|
var whey: AnyObject? = nil
|
|
}
|
|
|
|
private class Butter {
|
|
private func churn<T>(block: () throws -> T) throws -> T {
|
|
return try block()
|
|
}
|
|
}
|
|
|
|
struct Cow {
|
|
private var b : Butter
|
|
init() {
|
|
self.b = Butter()
|
|
}
|
|
|
|
func cheese() throws {
|
|
let a = Curds()
|
|
let b = Curds()
|
|
let c = Curds()
|
|
var err = 0
|
|
var newChild = 0
|
|
|
|
defer { }
|
|
|
|
try self.b.churn { return () }
|
|
}
|
|
}
|