EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP,subcode =0x0) on Swift when working with multi-dimensional arrays

筅森魡賤 提交于 2019-12-05 14:06:41

This sounds like a Swift compiler bug; the crash was due to an attempt to execute an illegal x86 instruction, so either the compiler generated invalid code or generated a branch to something that wasn't code at all or wasn't the beginning of an instruction.

Presumably you're beta-testing Xcode, so, if you don't already have an Apple Developer Connection account that lets you file bugs on Radar^WApple Bug Reporter, open an account, and then file a bug. (Apple may have given details on this as part of the Xcode download.)

I think it is no longer an issue in XCode6 beta 6. Here is my test code:

enum Form: Int {
    case Circle=1
    case Rectangle
    case Triangle
}


func testEnumArray () {
    let block1:[Form] = [Form.Circle, Form.Rectangle, Form.Triangle]
    let block2:[Form] = [Form.Rectangle, Form.Circle, Form.Triangle]
    let block3:[Form] = [Form.Rectangle, Form.Triangle, Form.Circle]
    let block4:[Form] = [Form.Circle, Form.Triangle, Form.Rectangle]
    let block5:[Form] = [Form.Triangle, Form.Circle, Form.Rectangle]
    let block6:[Form] = [Form.Triangle, Form.Rectangle, Form.Circle]
    var allBlocks = [block1, block2, block3, block4, block5, block6]
    println(allBlocks)

}

It does not throw exception anymore.

In addition, there is a syntax change since the question was posted:

Instead of let block6:Form[] we need to write let block6:[Form]

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!