Skip to content

[SR-815] Generic classes with default property initializers bug #43427

Closed as not planned
@swift-ci

Description

@swift-ci
Previous ID SR-815
Radar rdar://problem/25318716
Original Reporter wiruzx (JIRA User)
Type Bug
Environment

Swift 2.1.1, iOS 7
Swift 2.2, iOS 9.3

Additional Detail from JIRA
Votes 22
Component/s Compiler
Labels Bug, RunTimeCrash
Assignee None
Priority Medium

md5: ab6cd5d5f6905bbd52b11768623b6abf

is duplicated by:

  • SR-1659 Swift2.2.1 generics property crash

relates to:

  • SR-1201 All generic class crash on iOS 7

Issue Description:

class Test<T> {
    let object = NSObject()
    var value: T?
    
    func test() {
        print(object) // EXC_BAD_ACCESS here
    }
}

let x = Test<Int>()
x.test()

It doesn't matter if object will be NSObject or Swift's ref type.

Bug is not being reproduced if you either:

  • make class non-generic,

  • remove `value` property,

  • swap `object` and `value` properties declarations,

  • initialize object in `init`

This issue reproduces only on iOS 7

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfcrashBug: A crash, i.e., an abnormal termination of softwarerun-time crashBug → crash: Swift code crashed during execution

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions