Yes, surprising bug:
In OSX 10.14, playground OSX, this works
import simd
var viewMatrix = double4x4(1)
var modelMatrix = double4x4(1)
let modelViewMatrix = viewMatrix * modelMatrix
var m = modelViewMatrix.transpose.inverse
print(m)
simd_double4x4([[1.0, 0.0, 0.0, 0.0], [0.0, 1.0, 0.0, 0.0], [0.0, 0.0, 1.0, 0.0], [0.0, 0.0, 0.0, 1.0]])
The same crashes on Catalina.
But this works:
import simd
var viewMatrix = double4x4(1)
var modelMatrix = double4x4(1)
let modelViewMatrix = viewMatrix * modelMatrix
var m = modelViewMatrix.transpose.inverse
print(viewMatrix)
print(modelViewMatrix)
print(m)
simd_double4x4([[1.0, 0.0, 0.0, 0.0], [0.0, 1.0, 0.0, 0.0], [0.0, 0.0, 1.0, 0.0], [0.0, 0.0, 0.0, 1.0]])
simd_double4x4([[1.0, 0.0, 0.0, 0.0], [0.0, 1.0, 0.0, 0.0], [0.0, 0.0, 1.0, 0.0], [0.0, 0.0, 0.0, 1.0]])
simd_double4x4([[1.0, 0.0, 0.0, 0.0], [0.0, 1.0, 0.0, 0.0], [0.0, 0.0, 1.0, 0.0], [0.0, 0.0, 0.0, 1.0]])
Removing any of line 8 or 9 causes crash
This code crashes in an OSX App with EXC_BAD_ACCESS (code= EXC_i386_GPFLT) error.
Same error without transpose, just inverse (logic).the following causes crash in app but not in playground:
import simd
var viewMatrix = double4x4(1)
var m = viewMatrix.inverse
print(m)
I replaced double4x4 by float4x4, it works in code and in playground, even without additional print.
Tested with 3x3, same problem.
There is definitely a bug here. Should file a bug report (I'll do it).
EDITED: bug filed. FB7534934