I'm trying to run swix
in Swift 4. I've solved most of the initial issues that came up but there's one left I don't know enough about to resolve. It's three instances of the same error, see code bellow
var nc = __CLPK_integer(N)
dgetrf_(&nc, &nc, !y, &nc, &ipiv, &info)
Overlapping accesses to 'nc', but modification requires exclusive access; consider copying to a local variable
Any idea on how I can resolve this?
That is a consequence of SE-0176 Enforce Exclusive Access to Memory, which was implemented in Swift 4:
The __m
, __n
, and __lda
arguments of dgetrf_()
have the type
UnsafeMutablePointer<>
, even though the pointed-to variable is not mutated (but the compiler does not know that!) and
you pass the address of the same variable nc
to all three of them.
There are two possible solutions: Additional variable copies:
var nc1 = nc, nc2 = nc
dgetrf_(&nc, &nc1, &matrix, &nc2, &ipiv, &info)
Or withUnsafeMutablePointer
, because unsafe pointers do not use any active enforcement:
withUnsafeMutablePointer(to: &nc) {
dgetrf_($0, $0, &matrix, $0, &ipiv, &info)
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With