- 
                Notifications
    
You must be signed in to change notification settings  - Fork 10.6k
 
Closed as not planned
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfThe Swift compiler itselfcrashBug: A crash, i.e., an abnormal termination of softwareBug: A crash, i.e., an abnormal termination of softwarerun-time crashBug → crash: Swift code crashed during executionBug → crash: Swift code crashed during execution
Description
| 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
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfThe Swift compiler itselfcrashBug: A crash, i.e., an abnormal termination of softwareBug: A crash, i.e., an abnormal termination of softwarerun-time crashBug → crash: Swift code crashed during executionBug → crash: Swift code crashed during execution