-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Closed
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 softwareregressionrun-time crashBug → crash: Swift code crashed during executionBug → crash: Swift code crashed during executionswift 2.2
Description
| Previous ID | SR-1056 |
| Radar | rdar://problem/25339123 |
| Original Reporter | Abadjiev (JIRA User) |
| Type | Bug |
| Status | Resolved |
| Resolution | Done |
Environment
Xcode Version 7.3 (7D175)
Additional Detail from JIRA
| Votes | 0 |
| Component/s | Compiler |
| Labels | Bug, 2.2Regression, RunTimeCrash |
| Assignee | None |
| Priority | Medium |
md5: 6427dd7d1f2a9ce900f43e3cb7b07ed6
Issue Description:
With Swift 2.2 a certain type check can results in 100% reproducible crash. The key components are:
-
Have a class with an optional Generic field
-
Have a enum type to check against
-
Use a Struct with at least one String field and 2 String? fields
-
Check value type with `is` using the optional Enum type notation
-
100% guaranteed crash, usually "error: memory read failed for 0x0
This construction works as expected in previous versions of Swift (2.1, 2.0 and etc).
Example:
enum AnEnum {}
class AClass<T> {
var v: T?
func isEnumOptType() -> Bool {
return v is AnEnum?
}
}
struct AStruct {
let s1: String
let optS1: String?
let optS2: String?
}
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
let ss = AClass<AStruct>()
ss.isEnumOptType()
// crash will occur here or with the next statement if any
// ....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 softwareregressionrun-time crashBug → crash: Swift code crashed during executionBug → crash: Swift code crashed during executionswift 2.2