[swift-dev] isUniquelyReferenced issues

Patrick Pijnappel patrickpijnappel at gmail.com
Thu Mar 31 17:58:09 CDT 2016


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()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-dev/attachments/20160401/9cff9d67/attachment.html>


More information about the swift-dev mailing list