In trying to implement a COW type, but I'm running into problems with
isUniqueReferenced breaking in even fairly simple cases. For example (with
-O) the code below prints "bar: false", commenting out the print in
test() makes
it print "bar: true", and removing the var parameter var foo: Foo and using
var foo = foo instead breaks it again. Am I doing something wrong here?

class FooStorage { var x: Int = 0 }


struct Foo { var storage = FooStorage() }


func bar(var foo: Foo) {

print("bar: \(isUniquelyReferencedNonObjC(&foo.storage))")

}


func test() {

var foo = Foo()

print("test: \(isUniquelyReferencedNonObjC(&foo.storage))")

bar(foo)

}


test()
_______________________________________________
swift-dev mailing list
swift-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-dev

Reply via email to