I can't decipher this error message. This code compiles and runs
struct A {
var x: Int
}
var a = A(x: 123)
let result = withUnsafePointer(to: &a) {
print("ptr is \($0)")
// return 1
}
print("result is \(result)")
But, if you uncomment that return 1
line, the compile fails. Xcode highlights the &a
and says: Cannot pass immutable value of type 'inout A' as inout argument.
What does that mean? Maybe it's just a buggy error message?
(Xcode 8, beta 6)